08. December 2011 · Comments Off on Using SSH to secure Internet connections · Categories: Networking, Web · Tags: , ,
Two ways to use SSH to secure Internet connections are local port forwarding and dynamic port forwarding. Local port forwarding forwards web traffic from a server, while dynamic port forwarding transforms your SSH client into a SOCKS proxy server. Both can be useful for secure Internet access in insecure environments such as public networks. To use either, you need to be able to login onto a remote system. Both are easy to use.

Local Port Forwarding

Local port forwarding can be used to access specific sites from another machine. For example, to route traffic from www.somewebsite.com on a remote PC (user@yourdomain.com) to port 12345 on a client PC, the following could be entered into a command window:

ssh -L 12345:www.somewebsite1.com:80 user@yourdomain.com<host>

multiple connections may also be combined into one command as follows:

ssh -L 12345:www.somewebsite1.com:80 -L 23456:www.somewebsite2.com:80 user@yourdomain.com<host>

Use:
You just need to open a browser and point it to http://localhost:12345/ to securely access somewebsite1.com or http://localhost:23456/ to access somewebsite2.com.

Note: An IP address can also be used in place of yourdomain.com (e.g. user@192.168.1.1).

Dynamic Port Forwarding

Dynamic port forwarding is even more powerful as it allows you to securely connect to any web page and to bypass firewalls. To set it up, the following could be entered into a command window:

ssh -C -D 23456 user@yourdomain.com
  • The -C is optional and is used to enable compression, which can speed up connections
  • The -D enables dynamic port forwarding
  • 23456 is the port on the client PC

Use:
To use this connection, you will need to configure your browser to use a SOCKS proxy. See the following articles on how to do this for your browser:

Make Tech Easier – How to Secure Your Internet Connection via SSH

Ubuntu Help – SSHOpenSSHPortForwarding (see Dynamic Port Forwarding)

The How-to-Geek – 5 Cool Things You Can Do With an SSH Server (see SSH Tunneling)


Useful Related Articles:

Linux Magazine – Port Forwarding with SSH

OpenBSD Man Pages for SSH – Manual Pages

University of Victoria – An Introduction to the Black Art of Port Forwarding with SSH

Share
Bear

Bad Behavior has blocked 209 access attempts in the last 7 days.