Easy SSH and SCP Tunneling Using ProxyJump in Your SSH Config

Given a remote host “remote1.institution.edu” that has to be accessed through a gateway host, “gateway.institution.edu”, instead of issuing a complex tunnel command like:

ssh -p 2222 username1@gateway.institution.edu -t username2@remote1.institution.edu

you can make life a lot simpler by setting up your ~/.ssh/config file to make use of the ProxyJump feature:

Host gateway
    HostName     gateway.institution.edu
    User         username1
    Port         2222
Host remote1
    HostName     remote1.institution.edu
    User         username2
    ProxyJump    gateway

Now you can just:

ssh remote1

and be done with it!

Best of all (and most importantly), your scp commands are incredibly simplified as well, without requiring piping tar’s, ssh fuse mounts, or double-copying through staging directories on the gateway:

scp hello-world.txt remote1:workspaces/projects/greetings/
scp remote1:workspaces/projects/greetings/see-you-later-alligator.txt .