1

I can connect to machine m2 by logging in to m1 first:

[laptop]$ ssh ubuntu@m1.com
[m1]$ ssh ubuntu@m2.com
[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?

user124114
  • 121
  • 4

1 Answers1

3

You forgot to specify the port.

  ProxyCommand ssh -q m1 nc m2.com 22
HashHazard
  • 156
  • 4