Direct multi-hop ssh connection

How to use multi-hop ssh connection without needs to ssh multiple times?

As a example, you are connecting to through from 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:

  ProxyCommand ssh -q nc %h %p

Method 2:


ssh ssh

That is, you first log on and then ssh from there to

For both methods, Automatic Password-less SSH Login is your good friend.

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *