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

Use CVM to do ssh reverse tunnel

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

Share

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

[background]

There are three hosts A, S, B, and the system is all Linux. Host An and host B are in different private networks, and host S is a CVM with a public network IP. Both host An and host B can connect to host S through ssh. As shown below:

[demand]

Host A needs to connect to host B through host S.

[methods]

1. Set up the host S.

1.1. edit / etc/ssh/sshd_config file, modify or add:

GatewayPorts yes

Restart the sshd service.

Sudo service sshd restart

2. Set up host B.

2.1. method 1: use ssh

Ssh-fNR portS:localhost:22 userS@pubIpS# portS is an open port of host S # userS is a user of host S # pubIpS is the public IP of host S

2.2.2.Method 2: use autossh

The autossh-M 3456-NR portS:localhost:22 userS@pubIpS-p2cm-M parameter is not quite understood. It is probably listening through this port for automatic reconnection. # after entering the password, you can put it in the background with Ctrl-Z

3. After host A connects to host S through ssh. Connect host B like this:

Ssh userB@localhost-p portS# userB is the user of host B # portS is the same port as the portS in the previous step

Related reading: SSH reverse connection and Autossh

* walker * *

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