Basic SSH tunnel from localhost to www.example.com
ssh -C -N -f -L 80:127.0.0.1:80 root@www.example.com
Then just point your web browser to:
http://localhost/index.html
Tunnel through firewall to private network
Localhost port 80 outside the private network will tunnel to
10.0.0.1:80 on the private network at example.com.
ssh -C -N -f -L 80:10.0.0.1:80 user@firewall.example.com
More Information
-C sets compression, which is useful for wireless links.
-f says to go into the background after asking for your password.
-N says that you don't really want to login via ssh or execute a remote command.
You just want to start an SSH connection. This only makes sense when used with -L
-L specifies that you want to forward a port through an SSH tunnel.
80:127.0.0.0:80 is the port forwarding argument.
It means {local port}:{host address}:{host port}
So, your machine's port 80 will forward to port 80 at the host.
The interesting detail here is that the {host address} is
from the point of view of the machine you login to (firewall.example.com).
So 127.0.0.1 does not mean your localhost. It means localhost host on
You can tunnel through firewall.example.com to any address that firewall.example.com can see.
Older style
-n Redirect input from /dev/null.
-C Enable compression.
-f Fork into background after authentication.
ssh -C -n -L 110:mail.example.net:110 noah@mail.example.net -f nothing.sh
ssh -C -n -L 25:mail.example.net:25 noah@mail.example.net -f nothing.sh
ssh -C -n -L 25:mail.example.net:25 -L 110:mail.example.net:110 noah@mail.example.net -f nothing.sh
The "nothing.sh" script:
#!/bin/sh
while true; do sleep 53; done