SSH Intranet Port Forwarding combat

Source: Internet
Author: User

SSH Intranet Port Forwarding combat
Guide As you know, SSH is a secure transport protocol that is used more on the connection server. But in fact, in addition to this feature, its tunnel forwarding function is more attractive.

If the Linux server between the two intranet needs to log in with each other, or need to access a port on the intranet, worry about no public IP, you can use the method has Ngrok (https://ngrok.com/), but not convenient, we only need two SSH commands.

first, give the main character of this article, two SSH commands:
Remote port forwarding (a port forwarded by a remote server to the local intranet server port) SSH   -cfng-  R (key to command line)   2222 (remote server port): 127.0.0.1:22 (Local port)   
Local port forwarding (a port forwarded by a local intranet server to a remote server port) SSH   -cfng-  L (key to command line)    2222 (remote server port): 0.0.0.0:4444 (Local port)   
The command-line options explain:
-C: Compress data transfer. -F: Background authentication user/password, usually with-N, do not log on to the remote host. -N: Do not execute scripts or commands, usually with-F. -G: In the-l/-r/-d parameter, allow the remote host to connect to the established forwarding port, if this parameter is not added, only allow the local host to establish the connection. -L Local Port: Destination IP: Target Port-T does not assign TTY only do proxy with-Q Quiet mode, do not output error/warning message

The port number of the internal machine that needs to be accessible to the remote machine (port: 22)

After clear the above parameters, we use the following command to establish a remote SSH tunnel, in the intranet host execution

SSH   -cfng-r 2222:127.0.0.1:22  123.45.67.8

Now, in the IP is 123.45.67.8 machine, we can use the following command to log on to the intranet IP 192.168.0.100 machine.

Ssh-p 2222 localhost

Now the public network IP 123.45.67.8 host can be local access to the intranet server, the intranet client how to login it? , we only need to map the 4444 port of the intranet client to the port of 123.45.67.8 2222.

Now we need to forward it locally.

SSH  -cfng-   l  2222:0.0.0.0:4444   123.45.67.8

After execution, the local intranet client 4444 port has been connected with the 123.45.67.8 2222 port, and then the 123.45.67.8 2222 port and the intranet server 22 port connection, become a complete mapping chain.

Free to provide the latest Linux technology tutorials Books, for open-source technology enthusiasts to do more and better: http://www.linuxprobe.com/

SSH Intranet port forwarding combat

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.