Stabilize your Internet access via SSH tunnel

March 16, 2014 - 3 minute read -

There are situations when you are not satisfy the network environment you are currently in.

For example, the university upgrade the network connection for some student hostels. It turns out that the network connection looks to be faster, but you find out that the public IP address you use to connect to the Internet changes randomly each time you send an HTTP request. This might be a technology to speed up your network connection to websites. However, there are some websites (especially for banks and universities) that checks your IP address during your connection session.

You tried to connect the Internet via some well-known tools, but soon you found that those tools are forbidden by the firewall. Now you need a way to access the Internet safely and reliably.

Introduction

In this tutorial, I introduced an easy way to establish a secure and reliable connection to the Internet via SSH Tunnel.

SSH is a cryptographic network protocol for secure data communication. [SSH Tunnel] refers to tunnel all your network traffic via another computer.

Get a Virtual Machine on the Internet

If you are to tunnel your traffic, obviously you need a virtual (or physical) machine that is connected to the Internet.

Digital Ocean is a good choice for you. It offers cloud server as low as 5 dollars.

To create a server (or Droplet as what they call it) is very simple. Just follow the instruction will do.

The smallest server is enough for personal usage. You are suggested to choose a Region closed to you. If you are not sure which image, you may just select Ubuntu 12.04 x64.

After the server is created, the server IP and root password will be sent to you via email.

Connect via SSH Tunnel on OS X

Setting up Socks proxy

Update on 19 Novenmber 2014: iSSH is no longer recommended because of its bad user experience. Please continue with the next section to connect directly using terminal.

You may use iSSH to turn your SSH connection to a proxy.

When you open iSSH, key in the server ip in remote address, root as username and the password you get in your email, and select SOCKS Proxy. Then click connect.

Setting up Socks proxy using terminal

Please enter the following command using your terminal.

ssh -D <port-number> root@<ip-address>

The port number is used for sockes. you might choose any valid port you like, such as 8080, 12345.

The IP address is the address of your server.

After that, the remote server will ask you for your password. You should enter that. However, the password will not be display on the screen, neither any ‘*’ place holder, like most other terminal program.

When you finished logging in, you might minimize the terminal window, until you finish browsing.

Change network preferences

Then open the Network setting in System Preferences. Select the network you are currently connected to on the left panel. Click the Advance button on the right bottom corner.

In the pop up window, select the Proxies tab, check the SOCKS Proxy. Use 127.0.0.1 and the port you set in iSSH. Save the setting.

Now your computer should connect to the remote server already and all the application should visit the Internet through that server.

Remarks

Currently I’ve not tried SSH Tunnel on other operating system. You may share your experience with me.

Have a nice day and enjoy your stable network connection!