SSH is a great tool to open remote secure shells, this is widely used but a less know option SSH has is that can be used to acces the network of the remote server.

Usually if you work with VPS , by security you only open the ports essential, but imagine that you have to access a management web of the server that only can be accessed from loacalhost.

You can solve this with ssh tunneling

ssh remoteserver -L 8090:localhost:8080

This can be a bit confusing but let me explain the parts:

  • ssh remoteserver : Usual ssh remote shell
  • -L : Specifies port forwarding
  • 8089: Local port, the port where your browser will connect
  • localhost: Remote connection, ip address where the remote ssh will connect
  • 8080: Remote port where the remote ssh will connect

If you try this you will notice that it opens a remote shell, if you don’t need it you can additionally add the -N argument to avoid it