Forwarding of SSH

Source: Internet
Author: User
Tags ssh port ssh server
On the use of SSH portforwarding, there are already a lot of good articles on the web, I just draw two diagrams here to explain.

The first thing to remember is:

SSH port forwarding naturally requires an SSH connection, while the SSH connection is directional, from the SSH Client to the SSH Server.

The application we want to access is also directional, and the direction of application connection is also connected to the server side of the application from the client side of the application. For example, when we want to access a Web site on the Internet, the direction of HTTP applications is from our own host (Client) to the webserver in the distance.

If the connection between the SSH connection and the application is in the same direction, we will say that it is local forwarding.

Ssh-l <local port>:<remote host>:<remote port> <ssh

If the connection between the SSH connection and the application is different in the direction of the connection, we will say that it is a remote forwarding.

Ssh-r <local port>:<remote host>:<remote port> <ssh


Local forwarding listens to a port on the local machine, and all data accessing the port is transmitted through the SSH tunnel to the remote corresponding port, as the following example.

Local port forwarding binds to the Lookback interface, which means that only localhost or 127.0.0.1 can use native port forwarding, and other machine-initiated connections will only get "connection refused." To allow other machines to share this tunnel for forwarding, you need to use the Gatewayports keyword in the configuration file, or use the "-g" argument directly under the command line.

In addition, the <remote host> and <ssh hostname> in the local forwarding command can be different hosts.


Remote forwarding is the opposite of local forwarding, when the SSH tunnel is opened, the remote server listens on a port, and all access to the remote server specified port is routed through the tunnel to the local corresponding port, as the following example shows.

Here is a good article to introduce SSH portforwarding http://www.ibm.com/developerworks/cn/linux/l-cn-sshforward/


SSH-GFNL 5924:19.2.192.209:5924 aaa@192.168.24.41

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.