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

The realization method of SSH Session replication function under Linux

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly explains "the implementation of SSH Session replication function under Linux". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor to take you to learn "the implementation of SSH Session replication function under Linux"!

The code is as follows:

Under Linux/mac, add to $HOME/.ssh/config

Host *

ControlMaster auto

ControlPath / tmp/ssh-%r@%h

At this point, as long as you enter the password for the first SSH login, then the same Hosts will not be logged in.

Profile analysis

Man ssh_config 5

The code is as follows:

ControlPath

Specify the path to the control socket used for connection sharing as described in the ControlMaster section

Above or the string "none" to disable connection sharing. In the path,'% l' will be substituted by the

Local host name,'% h' will be substituted by the target host name,'% p 'the port, and'% r'by the remote

Login username. It is recommended that any ControlPath used for opportunistic connection sharing include at

Least% h,% p, and% r. This ensures that shared connections are uniquely identified.

% r is the login name of the remote machine

H is the remote machine name

Principle analysis

Strictly speaking, it is not really Session Copy, but can only be said to be a shared Socket.

When you log in for the first time, save Socket as a file to the path: / tmp/ssh-%r@%h

When logging in later, once the same host is found, the Socket will be reused.

Therefore, once the main process is forced to exit (Ctrl+C), other SSH is forced to exit.

The above process can be verified by ssh-v parameter and debug information.

At this point, I believe you have a deeper understanding of "the implementation of SSH Session replication under Linux". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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