08. December 2011 · Comments Off on Using SSH to secure Internet connections · Categories: Networking, Web · Tags: Linux, Security, Windows
Last updated on 09/23/2021

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 ([email protected]) to port 12345 on a client PC, the following could be entered into a command window:

ssh -L 12345:www.somewebsite1.com:80 [email protected]<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 [email protected]<host>

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

Note: An IP address can also be used in place of yourdomain.com (e.g. [email protected]).

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 [email protected]
  • 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

If you have found a spelling error, please, notify us by selecting that text and pressing Ctrl+Enter.

Share
conditions
">Bear

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

Spelling error report

The following text will be sent to our editors:

store