Ssh Tunneling

Port forwarding:

If you want to reach a forbidden port and you have ssh access to the remote box, you can run:

ssh -L 127.0.0.1:8888:192.168.13.66:18081 sensei@hostremote

$ ssh -L 127.0.0.1:8888:localhost:80 ocm@achtung
ocm@achtung's password:
Welcome to Ubuntu 11.10 (GNU/Linux 3.0.0-14-generic i686)

Now you can test it trying to telnet localhost at 8888 port:

ocm@ocmbox ~
$ telnet localhost 8888
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
get
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
<hr>
<address>Apache/2.2.20 (Ubuntu) Server at 127.0.0.1 Port 80</address>
</body></html>
Connection closed by foreign host.

ocm@ocmbox ~