Posted by: kezhong | August 31, 2011

Using SSH Tunnelling(Port Forwarding)

SSH tunnelling (also known as “Port Frowarding”) is very useful at work environment. For example, I want to configure and manage the switches that can be managed by the web-based management application in the datacenter, but I work at my office. Or I want to copy some files to the server in the datacenter from my office. Through using ssh tunnelling, I don’t need to go to datacenter to configure switches on the site, and don’t need to copy files to gateway and then copy from gateway to server.

Syntax:
ssh -L <localport>remoteip<remoteport> <username>@<bridgeip>

Case 1
From the above picture, there is a management server connectting to the management port of switches in datacenter. For the privacy, I suppose that the IP of the management server is 192.168.1.20, the IP of the switch1 is 10.1.1.2. At my fedora desktop, I open a terminal and type

$ ssh -L 8080:10.1.1.2:80 kezhong@192.168.1.20 cat –

and then open my browser, go to http://127.0.0.1:8080/

Case 2
From the above picture, I want to copy files from my pc to server1. Suppose that the IP of the gateway is 192.168.2.1, and the IP of the server1 is 10.2.2.5. Open a terminal and type

$ ssh -L 8082:10.2.2.5:22 kezhong@192.168.2.1 cat –

Open another terminal, type
$ scp -P8082 ubuntu-10.10-server-amd64.iso kezhong@localhost:/tmp/ubt.iso

Reference
http://www.rzg.mpg.de/networkservices/ssh-tunnelling-port-forwarding


Responses

  1. Hey there would you mind sharing which blog platform you’re working with? I’m planning to start my own blog in the near future but
    I’m having a hard time making a decision between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your design and style seems different then most blogs and I’m
    looking for something unique. P.S My apologies for getting off-topic but I had to ask!

  2. Excellent site you have here but I was curious about if you knew of
    any user discussion forums that cover the same topics
    discussed in this article? I’d really like to be a part of
    group where I can get responses from other experienced people that share the same interest.
    If you have any suggestions, please let me know.

    Thanks a lot!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: