Ssh: ProxyCommand forward host lookup fails

PROXYsshssh-tunnel

I am trying to do an ssh multihop from my local machine to a server called cluster, using a server called merlot in-between. As per http://sshmenu.sourceforge.net/articles/transparent-mulithop.html, this is how I've made my ~/.ssh/config :

Host merlot
  HostName merlot.stat.uconn.edu
  User vdeshpande
Host cluster
  HostName stats.phys.uconn.edu
  User vdeshpande
  ProxyCommand ssh -q merlot nc -q0 cluster 22

When I type ssh cluster into the terminal, I am prompted for the password of merlot. After I enter it, I get this error:

cluster: forward host lookup failed: Unknown host
ssh_exchange_identification: Connection closed by remote host

How do I fix this? I've checked that nc is installed. Also, I can ssh into merlot and then ssh into cluster.

Best Answer

You have the ProxyCommand wrong. There are two ways how to handle it:

Preffered way is using openssh native switch -w:

ProxyCommand ssh -W %h:%p proxy

The netcat version looks this way:

ProxyCommand ssh -q proxy nc %h %p

You can't use your aliases in the remote netcat command, because it doesn't know them. Great guide are substitutions %h, which is the HostName you specified above.

So for you case:

ProxyCommand ssh -q merlot nc -q0 %h 22