SSH / SCP Proxy Jump

Kevin FOO
2 min readApr 11, 2022

--

Before the pandemic, connecting to an Ubuntu instance with SSH in North Virginia was fast from Singapore. During the pandemic when everyone was working from home, the connection to North Virginia was terrible. Typing on the SSH terminal has a lag, where I already completed typing a word then a second or two later it appears on the terminal window.

To workaround this lag, I had to launch an extra Ubuntu instance in Singapore to use it as a jump host to reach my North Virginia instance. Assuming the IP and ID are these

# Singapore instance
# IP = 1.2.3.4
# ID = sg-user
# North Virginia instance
# IP = 6.7.8.9
# ID = us-user
# File path = ~/readme.txt

The command to jump host will be

ssh -J sg-user@1.2.3.4 us-user@6.7.8.9# equivalent command
ssh -oProxyJump=sg-user@1.2.3.4 us-user@6.7.8.9

Downloading some file through SCP command will be

scp -J sg-user@1.2.3.4 us-user@6.7.8.9:~/readme.txt .

The jump host is not limited to one. It can be jumped through multiple hosts separated by comma. Assuming the IP and ID are these

# Singapore instance
# IP = 1.2.3.4
# ID = sg-user
# London instance
# IP = 2.3.4.5
# ID = uk-user
# North Virginia instance
# IP = 6.7.8.9
# ID = us-user
# File path = ~/readme.txt

The multiple host jump command will be

ssh -J sg-user@1.2.3.4,uk-user@2.3.4.5 us-user@6.7.8.9# equivalent command
ssh -oProxyJump=sg-user@1.2.3.4,uk-user@2.3.4.5 us-user@6.7.8.9

The equivalent SCP command will be

scp -J sg-user@1.2.3.4,uk-user@2.3.4.5 us-user@6.7.8.9:~/readme.txt .

HTTP Proxy

Command below SSH to a remote endpoint and creates a SOCKS proxy locally.

ssh -p <ssh_port> -D <proxy_port> -f -C -q -N username@domain_or_ip

# -p Port that the SSH server is listening
# -D The SOCKS proxy port you intending to create 1025-65536
# -f Forks the process to the background
# -C Compresses the data before sending
# -q Quiet mode
# -N Tells SSH that no command will be sent once the tunnel is up

# Example
ssh -p 8022 -D 3128 -f -C -q -N ubuntu@192.168.1.234

< Back to all the stories I had written

--

--

Kevin FOO
Kevin FOO

Written by Kevin FOO

A software engineer, a rock climbing, inline skating enthusiast, a husband, a father.