Direct multi-hop ssh connection
Posted on In QAHow to use multi-hop ssh connection without needs to ssh multiple times?
As a example, you are connecting to server.example.com through proxy.example.com from laptop.example.com as follows:
laptop ----> proxy ----> server
2 possible methods:
Method 1: Use the similar method as in Directly SSH to hosts using internal IPs through the gateway. Add this to your ~/.ssh/config
on laptop:
Host server.example.com
ProxyCommand ssh -q proxy.example.org nc %h %p
Method 2:
Run
ssh proxy.example.com ssh server.example.com
That is, you first log on proxy.example.com and then ssh from there to server.example.com.
For both methods, Automatic Password-less SSH Login is your good friend.