Apr '10 15

SSH and port forwarding

I seem to forget every time i use ssh for port forwarding which side goes where in the syntax, so to make it easy here it is.

Forward a local port to a remote port at the far end, ie: tunnel a web server behind the firewall

  • do the normal session in putty on the first page
  • in the ssh->tunnels, source port is your local port, then “add” destination ip:port, leave as “local”

Reverse Tunnel from the remote end, so you can ssh to a pc behind a firewall

  • log into the box at the far end (eg: terminal server then putty)
  • ssh -f -g -N -R 2210:localhost:22 thedragon.kicks-ass.org
  • then you can ssh to 2210 locally and it appears to be a ssh at the remote end

May need to set ServerAliveInterval 30 and ServerAliveCountMax 1000 in the ssh_config