September 09, 2024
I had a need to access some things on the internet from a different IP address, because of temporary issues with my regular IP. So I thought, what if I could send that data through an SSH connection via my VPS, and access stuff from the IP of my VPS? Turns out that’s totally possible, here’s how you do it.
Let’s call the VPS the “jump server”.
First, you need the jump server to have SSH set up.
Then, on your computer, open a terminal, and set up an SSH tunnel:
ssh -ND 0.0.0.0:22080 jumpserver
Replace jumpserver
with the username and IP for your jump server, and add any other flags you normally use to connect via SSH.
The additional flags, explained:
-N
: don’t execute a remote command. In other words, you don’t get an SSH shell.-D 127.0.0.1:22080
: allocate a socket to listen to port 22080 (arbitrary, choose whatever you want) on localhost. Whenever an application connects to this port, the connection is forwarded through the SSH connection, and the same application connection is done from the remote machine. The channel uses a SOCKS proxy. So if a browser connects to IP address X on port 443, and it’s proxied via localhost port 22080, the connection will go through the SSH session, and then the jump server will connect to IP address X on port 443.You won’t see any output, it’ll look like the command is hanging. That’s good; it means it’s working.
Now you need your client apps to use this proxy. I won’t list everything here, only the ones I used; you can find the steps for others with a web search.
For Firefox: go to settings (about:preferences), network settings, “Configure how Firefox connects to the internet”, click the settings button. In the window that opens, click ‘Manual proxy configuration’, next to “SOCKS host” enter localhost and port 22080, click ok. Then, go to some IP checking website to see if it’s working.
For Thunderbird: click the cog for settings, connection, next to “Configure how Thunderbird connects to the Internet” click Settings. In the window that opens, click ‘Manual proxy configuration’, next to “SOCKS host” enter localhost and port 22080, click ok.
You can also proxy your whole system like this; the exact steps depend on the OS and/or distro.