My desktop is Ubuntu. There is a host class with name my_host_machine, which includes several servers like: my_host_machine_1, my_host_machine001,my_host_machine__123, etc. It's uncertain which server will be connected when I ssh my_host_machine. And directly connecting to a server like my_host_machine_1 gets time out.

We are supposed to use one of those servers as a proxy to get access to another server a_remote_server. Directly ssh to a_remote_server from the local desktop is forbidden.

My question is, can I directly connect to a_remote_server from my desktop via proxy command?

I tried setting ~/.ssh/config on my local desktop as on this page.

Host Remote
  HostName a_remote_server
  User Tom
  Port 22
  ProxyCommand ssh Tom@my_host_machine nc %h %p %r

It returns

nc: port range not valid ssh_exchange_identification: Connection closed by remote host

What's wrong with my config file?

1 Answer 1



ProxyCommand ssh -W %h:%p Tom@my_host_machine

or just

ProxyCommand ssh Tom@my_host_machine nc %h %p

netcat does not accept username as a argument.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .