Turn a Linux VPS into SSH/SOCKS5 proxy server

You can hide what you’re doing on the Internet from anyone who might be sniffing your link, bypass firewall or corporate/government blocking, access restricted services like Pandora/Netflix from outside of the US or re-route your traffic to a game server to have better response time. Instead of paying for shitty lowerping or VPN services why not rent a VPS for 5 bux and be able to run a SOCKS5 proxy server, a OpenVPN server, a VoIP server, a webserver, your own cloud drive and many more by yourself?

If you don’t own an VPS already I’d recommend renting one from DigitalOcean. Their server specs, service, network speed and price can’t be beat by any other provider. The cheapest VPS cost $5/month or $0.007/hr and is more than enough for our purpose.

The easiest way, less than 10 mins to setup.

Step 1. Determine the server location that works best for you. Generally the one that is closest to you and is between you and the target server(s) would be best but there are other things to consider as well. You can always terminate and create a new server with DigitalOcean if the response time of the current server isn’t to your liking since the fee is charged on hourly usage, not flat rate.

In my case I’m from SE Asia and I want to use this proxy server to reduce ping in various NA game servers and by-pass government censorship. A server located in Singapore would be my best option performance-wise. But I’d also like to watch Netflix/Hulu streams and other US only services so NA West Coast is my best available choice.

Step 2A: Download and install SSH client of choice. I’d recommend using PuTTY

Configure PuTTY like the example above. Replace the username and hostname with your own then hit Open. If your VPS provider is DigitalOcean you will be emailed a random root password for the first time login and will be promted to change your password after. Restart PuTTY and login with the new password, leave the console open.

Step 2B (Optional): Setup a SOCKS5 server for your mobile devices or to share with other people.

First Step

Enter ssh -f -N -D 0.0.0.0:1080 localhost in the console will set up a SOCKS5 proxy on YourServerIP:PortNumber, when used will automatically tunnel your requests via your server. Change the port number 1080 to the number of your choice. It is a good idea to avoid well known ports to prevent it being easily guessed.

Warning: This is a potential security risk if given to an untrusted party or not configured properly.

Use ssh -N -D 0.0.0.0:1080 localhost if you want the server to stop forwarding requests as soon as you close PuTTY. Alternatively implement access control via iptables. For example, to allow only people from the ip 1.2.3.4 to use the SOCKS5 proxy, enter the following iptables rules to the console:

sudo iptables -A INPUT --src 1.2.3.4 -p tcp --dport 1080 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 1080 -j REJECT

Step 3 Using SSH/SOCKS5 proxy

For internet browsers or applications with proxy settings: Simply enter 127.0.0.1 and 1080 for port (if followed step 2A) in the SOCKS5 section of your browser proxy setting or serverip:port (if followed step 2B). Confirm your IP address has been masked with your server here.

Proxy Setting

For other applications or games:

Download FreeCap (Free)

Proxifier (Paid, but if you know where to look…)

Configuration:

FreeCap:

Make sure you run the program as administrator. In File > Settings > Proxy Settings. Add 127.0.0.1:1080 and select SOCKS v5 protocol (step 2A), yourserverip:port (step 2B)

File > New Application > Browser to .exe file of the application to add. Double click to run it Socksified!

Proxifier:

Profile > Proxy Servers… Add 127.0.0.1 and select SOCKS v5 protocol (step 2A) or yourserverip:port (step 2B)

Profile > Proxification Rules. Add application or .exe name, port, target host manually and choose the SOCKS5 server from the Action list. Alternatively change the action for Localhost rule from Direct (ignore proxy settings) to SOCKS5 server to forward all traffics from your computer through the server.

For Android devices I’d recommend getting ProxyDroid app from Google Play. If you’re an Apple sheep then figure it out yourself. :^)

AnhTurn a Linux VPS into SSH/SOCKS5 proxy server

Leave a Reply

Your email address will not be published. Required fields are marked *