SSH Tunnelling/Forwarding

24th March 2012 (12 years ago)

This allows you to bind a local port to a port on a remote server to make it public:

ssh -N -R <localport>:localhost:<remoteport> <user@remotehost>

This lets you bind a port on your server to a local one:

ssh -N <user@remotehost> -L <localport>:localhost:<remoteport>

You will probably need to add GatewayPorts yes to /etc/ssh/sshd_config on the server side.

The -v to -vvv flags show verbose information.

The -N flag is useful for tunnelling as it won't execute a remote command.