SSH Tunnelling

Establishing an SSH Tunnel
ssh -f -L localport:remotehost:remoteport -4 user@remotehost tail -f /dev/null
-f Instructs SSH to run in the background
-L localport:remotehost:remoteport Create the SSH Tunnel
-4 Make the Tunnel ipv4 only
tail -f /dev/null This is a low-overhead command required to keep the connection open

lsof -i tcp:1234
This is a useful command to look at connections on TCP port 1234

2 comments

  1. Instead of using `tail -f /dev/null’, you may use the -N option. This tells ssh not to execute any command. Is there anything I missed?

  2. You can also add the -g option if you want other hosts to be able to use your tunnel (be careful as any host that is allowed access to the shared port will be able to use the tunnel).

Leave a comment