ProxyCommand you specify is not executed on the remote host. It is run on the local (client) side as an alternative connection method to opening a TCP connection (typically port 22) to the remote host. The executable run by
ProxyCommand is expected to communicate with the local ssh client through
stdin as a proxy to the socket's own
send(), but otherwise should behave from the client's perspective as a byte for byte replacement of a TCP session to an actual ssh server.
Typically the usage of
ProxyCommand is to setup a ssh tunnel through one server to connect to a secondary server that otherwise would not be able to establish a direct connection. Using the ssh client with a
netcat (nc) command can accomplish this, where
netcat handles the linking of
send() on the socket side, and
When you invoke a
ProxyCommand that does not establish
stdin to match what the SSH protocol expects in order to negotiate a proper SSH transport, the client bails out with the error:
ssh_exchange_identification: Connection closed by remote host.
If what you actually intend is for the command to be executed on the remote host after the ssh session is established and authenticated, you can include it at the end of the ssh command line (without
ProxyCommand) and the ssh client will invoke that command on the remote host, instead of an interactive shell.
ssh root@ubuntu ls instead.