3

I am trying to ssh from Computer-A to Computer-C by tunnelling through Computer-B with the key on Computer-B. I have already shared keys from Computer-A to Computer-B and from Computer-B to Computer-C

This works on computerA to connect to computerC without a password or intervention:

ssh -t computerB ssh computerC

If I put this same command in my ssh_config on computerA it just hangs

Host = computerC
  ProxyCommand = ssh -t computerB ssh computerC

i get the following error: Pseudo-terminal will not be allocated because stdin is not a terminal.

jbrass
  • 941
  • 7
  • 26

1 Answers1

2

Try this:

Host computerC
  ProxyCommand ssh computerB nc %h %p

You may have to alter nc (netcat) if it has a different name or is not in the default PATH on computerB.


Explanation:

ssh -t computerB ssh computerC logs you in to computerB over ssh, and then from computerB logs you in to computerC over ssh. For each hop --- from A to B, and then B to C --- ssh sets up a TCP connection to port 22 over which the encrypted data flows.

ProxyCommand disables opening a TCP connection, and instead specifies a custom command to open the connection. The other side of the connection should have a ssh daemon on the other side that the ssh client can talk to --- a shell is of no use to it at all.

dave4420
  • 46,404
  • 6
  • 118
  • 152