Total Pageviews

Monday 29 April 2024

SSH connection via SOCKS proxy, and FTP connection via SOCKS proxy

 

Since the SOCKS proxy performs at Layer 5 of the OSI model (the session layer), you may use it with many applications that work in a Layer higher than Layer 5, such as FTP, Telnet, HTTP, SSH…

SSH via SOCKS proxy

For example, if you want to SSH to a Far_Away_Host via the SOCKS proxy we just created. You can do:

$ ssh -o ProxyCommand='nc -x localhost:12345 %h %p' username@Far_Away_Host

After login into the Far_Away_Host, you can check that you are deemed as connected from SSH_remote_host_IP instead of your local machine!

username@Far_Away_Host$ who  
username pts/3 2021-03-29 14:08 (SSH_remote_host_IP)

FTP via SOCKS proxy

Another example is the SOCKS proxy setting in FileZilla, an FTP client:

SOCKS proxy setting in FileZilla

Further Reading

There is a convenient tool — sshuttle suggested by smw on Hacker News. It works as a poor man’s VPN using ssh, which also doesn’t require admin on the remote machine. The manual is here. It can be easily installed on, e.g., macOS and Ubuntu via:

# on Ubuntu
$ sudo apt install sshuttle
# on macOS, installed by macports
$ sudo port install sshuttle

The simplest way to use it is:

$ sshuttle -r username@SSH_remote_host_IP 0.0.0.0/0

, which forwards all traffics on your local machine to the remote host!

No comments:

Post a Comment