SSH tunnelling

Currently, I wanted to ssh to a remote server from my computer. But, the network where my computer resides has blocked the ssh port. I could not do it the normal way. So, I used the SSH tunneling technique to bypass this strict policy.

Here is how I did it:

1. Create an SSH tunnel from my machine (localhost) through a un-blocked server (e.g. the firewall), the only computer that can make ssh connections to the outside world, to the server I want. (Luckily, I have access to the firewall of the network)

$ ssh -L 2022:myremoteserver.com:22 firewall_user@firewalldomain.com

This will ask me to provide the password of the firewall_user. It will open a tunnel from my local machine at port 2022 to the ssh port (22) of the firewall. Keep the terminal window open and move to the next step.

To

2. Open another terminal window and SSH through the tunnel by the following command:

$ ssh -l remote_user -p 2022 localhost

This command will ask me the password of the remote_user user in the myremoteserver.com, (but @localhost, because we connect through the tunnel):

remote_user@localhost's password:


And then I have access to the remote server's shell, beautifully! \m/






References: 

http://inside.mines.edu/~gmurray/HowTo/sshNotes.html

Comments