Using a server service through a SSH tunnel

by Roberto on April 20, 2009

in General

If you have access to a server only through SSH, you can yet access all the others server services without the need to forward other ports on the router or firewall.
Here is how :

  1. Open a console on your client
  2. Type : ssh -L [local port]:localhost:[remote port] [username]@[remote server]

From now on you can reach the remote service accessing to localhost on port [local port].

Parameters :

  • [local port] : the port you'll use on your client
  • [remote port] : the port you need to reach on the remote server
  • [username] : your username on the remote server
  • [remote server] : remote server public hostname or ip address

So, for example, if you want to access the webserver running on the remote server on the port 80, you'll write :
ssh -L 8080:localhost:80 [username]@[remote server]

Opening in your browser the url http://localhost:8080 you'll be able to access the remote webserver.

A similar solution can be implemented using Zebedee that doesn't require a SSH access because has its own authentication and encryption routines.

Leave a Comment

Previous post:

Next post: