Multi-hop SSH Connection

The case is as follows:

You have a server, let’s name it “server2” that you need to SSH to, but unfortunately this server is not directly accessible, as you can SSH to it only through another server, let’s call it “server1”.

Normally, what you will do is connect via SSH to “server1” first, then connect to “server2”. This is really annoying; having to run two commands to access a single server and having to wait for their completion.

All you have to do is the following command to be able to access “server2” using a single command:

ssh -A -t user@server1 ssh -A -t user@server2

But, there is only one prerequisite to this, which needs to be done once and for all, that is the password-less login using the Private-Public key authentication (ssh-keygen, ssh-copy-id …etc)


About SoCRaT

Systems Engineer, OSS & Linux Geek
This entry was posted in Linux, Uncategorized and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s