Thursday, December 4, 2008

Port Forwarding using SSH

Using SSH port forwarding we can access various kinds of TCP based servers ( i.e HTTPD, SMTP, POP, IMAP, etc.) across a firewall that prevents direct access.


Command :

 $  ssh < remote_server > -L< local free listener port>:localhost:< remote listener port> 



Example Scenario :

IF you have ssh access on a remote machine(say rhost) but, you don't have any other access including http. If you want view some web pages which are hosted on same remote machine(i.e rhost) through http request, then apply following "ssh port forward" command.


 $  ssh rhost -L8888:localhost:80 

here rhost is remote host/server name (replace with your server name)
8888 is free port on your machine
80 is default listener port on remote machine.



now you can access web pages which are hosted on rhost machine using "http://localhost:8888".

No comments: