I was setting up a distributed monitoring system recently. At local machine, I has a program named “proga”, trying to access a remote server named “remote” at port 5667. However, the port is blocked by the enterprise firewall.

This is easy to solve by SSH tunneling.

ssh -f roman10@remote -L 5668:remote:5667 –N

This command sets up the SSH tunnel for accessing port 5667 of remote server from my localhost.

-f: ssh goes to background before it executes the command.

roman10: my user name at remote server

-L 5668:remote:5667: forward the traffic received at localhost 5668 to remote server at 5667. More generally, -L [bind_address:]port:host:hostport: Specifies that the given port on the local (client) host is to be forwarded to the given host and port on the remote side.

-N: do not execute a remote command.

After authentication, the tunnel will be set up. After that, I can simply access the remote port by sending traffic to 5668 at localhost.

One can make sure the remote 5667 port is open by the command at remote host,

netstat -nan | grep 5667

After that, use telnet to test the tunnel at localhost,

telnet localhost 5668

If it connects, we have set up the SSH tunnel successfully.

 

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Set your Twitter account name in your settings to use the TwitterBar Section.