HowTo Replace Multi-hop SSH with One Command

As an engineer in a software company, it often happens to need a remote access to my own workstation at office. However, I cannot directly SSH to my own PC as it is within an internal network — inaccessible over the internet. So, I mainly have to connect to an intermediate server and SSH to my own PC from there, that is two jumps. Suppose that you are desiring to go through this path several times a day! Kinda problem!

I searched for a solution over the web and came across one which configures SSH to transparent the intermediate connection, that is connection to the intermediate server. Hence, you can directly connect to your personal workstation with only one simple command. Here’s the solution

Suppose that I must first connect to the userver and then connect to the workstation. Then, you can just add the following lines to you ~/.ssh/config file (create a new if it does not exist):

Host *
ServerAliveCountMax 4
ServerAliveInterval 15
Host workstation
Hostname workstation
User userworkstation
ProxyCommand ssh userserver@userver -W %h:%p

Now, you can simply use the command below to bypass the intermediate connection and access your workstation:

ssh workstation

Wish you luck

A single golf clap? Or a long standing ovation?

By clapping more or less, you can signal to us which stories really stand out.