I can connect to machine m2
by logging in to m1
first:
[laptop]$ ssh [email protected]
[m1]$ ssh [email protected]
[m2]$ # i'm in!
Both machines use SSH key to log in (not passwords), and it works.
But when I try to automate this with SSH proxying, by using the following config:
Host m1
ForwardAgent yes
User ubuntu
HostName m1.com
Host m2
ForwardAgent yes
User ubuntu
ProxyCommand ssh -q m1 nc m2.com
it fails with:
[laptop]$ ssh m1
[m1]$ # ok, works
[laptop]$ ssh m2
no port[s] to connect to
ssh_exchange_identification: Connection closed by remote host
Why can I connect manually to m2.com
, but not in two hops via config?
How to fix it?