
f is optional, requests ssh to go to background just before command execution.Typically, this will be 22, however there could be some security controls in place that do not allow SSH on the common port. -p 20622 is optional, it tells ssh to establish the tunnel on the remote port 20622.username is the username for the jump host.N optional, directs ssh to not execute remote commands.C optional, is used to compress data in the tunnel to conserve bandwidth.Ensure that this port is not already being used on your local machine. This will open a SOCKS proxy on port 4000.

-D 4000 is used for dynamic application-level port forwarding.We will be using Firefox, however many other browsers such as Google Chrome support SOCKS5.Īt the command-line, run the following: ssh -D 4000 -C -N -q -f -p 64356 The SOCKS proxy will send traffic via the SSH tunnel to the jump host. In this example, we will set up a local SOCKS proxy and SSH tunnel. Let’s say we wanted to use the same jump host in the example above and send our web traffic to the jumphost to access a website hosted behind it on an internal network. Multiple SOCKS proxies can be created, meaning multiple endpoints can be configured to proxy your local machine’s traffic.

You can use this technique to access internal websites that remain only accessible behind a jump host. This is useful for browsing to a website that is normally not directly accessible. This allows you to proxy application traffic and send it to a jump host. SOCKS ProxyĪnother cool feature enabled on many systems is SOCKS. To terminate the ssh tunnel, run ps aux | grep ssh, search for the correct tunnel and PID, and then run kill 12345 replacing 12345 with the PID on your machine. So if you were to make another connection, you will see an additional netstat entry with another local port generated for the second connection. This allows for multiple connections to be forwarded through port 4001. The SSH client is forarding traffic over local port 4001 to randomly selected open local port 64356 which is then sent over the SSH tunnel, which eventually lands at 192.168.20.10 port 22. Observe the output:Įvery 2.0s: netstat -abn | grep 4001 My-Cool-Macbook.local: Mon Sep 16 16:08:03 2019 This will run the command every 2 seconds and print the output to the screen. If you are curious about what your system is doing from a network perspective, open a separate terminal and run the following command before you create the SSH tunnel: This is useful if ssh is going to ask for passwords or passphrases, but the user wants it in the background.
