Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use SSH to realize Port Mapping under Linux system

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "how to use SSH to achieve port mapping under the Linux system". In the daily operation, I believe that many people have doubts about how to use SSH to achieve port mapping under the Linux system. I have consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubt of "how to use SSH to achieve port mapping in the Linux system". Next, please follow the editor to study!

You can bind a port remote_port of the remote server to the local port port, where-C is for data compression,-f is a background operation, and only turns to the foreground when prompted for a username password. -N does not execute the remote command, which is useful when it is only forwarded by the port. -g allows the remote host to connect to the local forwarding port. -R indicates that the remote host port is mapped to the local port. If-L, the local port is mapped to the remote host port.

Three powerful ports of ssh forward commands:

Forward to remote: ssh-C-f-N-g-L local port: destination IP: destination port username @ destination IP

Forward to local: ssh-C-f-N-g-R local port: destination IP: target port username @ target IP

The code is as follows:

Ssh-C-f-N-g-D listen_port user@Tunnel_Host

-C: compressed data transmission.

-f: authenticate the user / password in the background, usually used with-N, without logging in to the remote host.

-N: does not execute scripts or commands, usually used with-f.

-g: in the-L/-R/-D parameter, the remote host is allowed to connect to the established forwarding port. If this parameter is not added, only the local host is allowed to establish a connection.

-L local port: target IP: target port

Forwards a port of the local machine (client) to the designated port of the remote designated machine. The working principle is that a socket listening port port is assigned on the local machine. Once there is a connection on this port, the connection is forwarded through a secure channel, and a connection is established between the remote host and the hostport port of host. You can specify port forwarding in the configuration file. Only root can forward privileged ports. The IPv6 address is described in another format: port/host/hostport

-R local port: target IP: target port

Forwards a port of the remote host (server) to the designated port of the specified machine on the local side. The working principle is that a socket listening port port is assigned on the remote host. Once there is a connection on this port, the connection is transferred out through a secure channel, and the local host establishes a connection with the hostport port of the host. You can specify port forwarding in the configuration file. Only by logging in to the remote host with root can you forward the privileged port. The IPv6 address is described in another format: port/host/hostport

-p: the sshd service port of the ssd server logged in.

-D port

Specify a local machine for dynamic''application port forwarding. The working principle is that a socket listening port port is assigned on the local machine. Once there is a connection on this port, the connection is forwarded through a secure channel. According to the protocol of the application program, you can determine where the remote host will connect. SOCKS4 protocol is currently supported and will act as a SOCKS4 server. Only root can forward privileged ports. You can specify the forwarding of dynamic ports in the configuration file. >

Application example

1. Forward port 80 access destined for this machine to port 8080 of 174.139.66

The code is as follows:

Ssh-C-f-N-g-L 80 master@174.139.9.66 174.139.66 master@174.139.9.66

two。 Talk about the 8080 access to 174.139.9.66 forwarded to port 80 of this machine.

The code is as follows:

Ssh-C-f-N-g-R 80 master@174.139.9.66 174.139.66 master@174.139.9.66

At this point, the study on "how to use SSH to achieve port mapping in the Linux system" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report