Setting-up SSH-tunnel for VPN?
I have a laptop running Ubuntu. I also rent a VPS running Ubuntu. I've bought a paid VPN-service, which I use on my laptop.
I was wondering how I can set-up a SSH-tunnel or something similar, from my laptop to the VPS I'm renting, so I then can run VPN (from my laptop) "through" it (to the VPS), to the VPN-server. The reason I wish to do so, is that a place I often work blocks my VPN-service, but not my SSHing to my VPS...
While I have been using Linux for a while, I'm a novice when it comes to setting-up virtual network-devices, advanced routing, and so on... so please spoonfeed me (using small words and colorful pictures ;-)
I have been googling and looking at various answers on the StackExchange-network, but not seems to be exactly what I'm after. SSH-tunneling seemed promising, but since I don't have/know an exact domain and port for my VPN, I couldn't figure out how to use it... I guess I may need to set-up some virtual network-device on my laptop (which ends on the VPS), and connect VPN through it - but how to do this, sadly goes over my head.
Solution 1:
The easiest why to tunnel all traffic through SSH similar to a VPN is to use the sshuttle
package.
First, install the package:
sudo apt-get install sshuttle
Then connect to the SSH tunnel and redirect your default route to go through it:
sshuttle -vv --dns -r username@sshserver[:port] 0.0.0.0/0
This will forward all TCP traffic through your SSH connection, including DNS requests. If you still want DNS handled locally, you can remove the --dns
flag.
Solution 2:
Create a tunnel
ssh -fND 7001 yourVPN
Open Chromium to use Proxy
chromium-browser --proxy-server=socks5://localhost:7001
Notes
- 7001 is the port and can be changed, so long that they both match
- You can also pass
--user-data-dir=/tmp/someDir
tochromium
to use a different instance of Chromium