How to forward a port using ssh

port forwarding using ssh

If you are:
 * working on a computer A that has an ssh client installed
 * have an ssh account (username) on a computer B and you can connect to username from computer A, with the following url (or IP): b
 * want to connect to a computer C but you don't have direct access (because of proxy's and/or firewalls), with the following url (or IP): c

You will be able to create an ssh tunneling or port forwarding that will work with any application connected to localhost or the local IP of your computer. Your application contacts localhost on port pA. The ssh tunnel will forward this to your desired port pC on computer C.

On computer A, open a terminal and type: ssh -N -L pA:c:pC username@b

Then enter your pasword for username.

Now you can use your application on localhost with port pA in order to connect to c on port pC..

Example: if your account on computer B is bill, if computer B is at pc25.example.com, if computer C is at 80.75.65.25, if you want to connect to subversion on computer C on port 7935, then type in your terminal: ssh -N -L 9686:80.75.65.25:7935 bill@pc25.example.com

And then in a new terminal: svn co svn://localhost:9686/repository_name

It will have the same effect as when you type: svn co svn://80.75.65.25:7935/repository_name