SSH Tunneling

Problem: it is necessary to connect your local PC to a remote PC using a service that uses an unencrypted connection, or a port number not allowed on the network. Instead, we would like to perform this connection using an encrypted mechanism and an allowed port number.

Solution: SSH Tunneling. This method works as long as the remote computer has an SSH server, and you know which port it is listening to, usually port 22.

Example: the service (such as a Remote Desktop Application) uses port 4000 between the client and server. We want to tunnel this application through port 22, using SSH which is an encrypted mechanism. Here, ‘user’ and ‘server_address’ have to be replaced by your actual user name and name or IP address of the remote computer.

>> ssh -L 4000:localhost:4000 user@server_address

If we needed to use a port different from 22, we have to use the argument ‘-p new_port_number’, as follows (if port 345 is to be used):

>> ssh -p 345 -L 4000:localhost:4000 user@server_address

After the SSH tunnel has been established, the client and server ends of the application (Remote Desktop, for example) have to be launched, and should be able to communicate.