linux - ssh into remote host after multi-hop ssh tunnel -


i used instructions here generate multi-hop ssh-tunnel:

http://blog.naenius.com/2011/06/ssh-tunneling-across-multiple-hosts-in-linux/

which builds tunnel

'localhost' -> 'host1' -> 'host2'

in particular, used:

ssh -t -t -l[local_port]:localhost:[port_on_a] [user]@[server_a] 'ssh -l[port_on_a]:localhost:[port_on_b] [user]@[server_b]' 

which, after executing, opens terminal on host2.

now have done that, connect via ssh directly host2 localhost, have naively expected achieved by:

ssh localhost:[local_port] 

however, get:

ssh: not resolve hostname localhost:2345: name or service not known

any ideas?

edit:

tried machine ip:

ssh [machine_ip]:[local_port] 

but not work.

however, here's work

if do:

ssh -l 1234:[server_b]:22 [user]@[server_a] 

i can copy directly machine server_b via:

scp -p 1234 local_path_to_file [user]@127.0.0.01:

but this:

ssh 127.0.0.01:1234 

returns

ssh: not resolve hostname 127.0.0.01:1234: name or service not known

not sure if that's revealing

edit2: /etc/hosts

cat /etc/hosts                                                                                                                                                     127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6 

ssh 127.0.0.01:1234 

the openssh ssh utility, you're using here, doesn't permit specify port way. it's taking entire string "127.0.0.01:1234" , trying resolve hostname.

the correct way run is:

ssh -p 1234 127.0.0.1 

Comments