Sunday, November 8, 2009

Reverse ssh

My personal computer is on a private home network behind a wireless AP which has a public IP given by my ISP. So, if I'm at work how do I access my personal computer at home. The solution is as follows :-

First open a reverse connection from the personal computer to the work machine :-

Here 192.168.1.101 is the private IP of my home machine.

ssh -NR 2200:192.168.1.101:22 work-username@work-machine-IP

Now you can ssh into your home machine from your workplace by typing the following on the work machine :-

ssh -p 2200 home-username@localhost

TADA!!! you are done :)

You can copy files to your home machine by doing :-

scp -P 2200 filename home-username@localhost:~