溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Linux下SSH Session復制功能的實現方法

發布時間:2021-09-02 19:42:39 來源:億速云 閱讀:585 作者:chen 欄目:系統運維

本篇內容主要講解“Linux下SSH Session復制功能的實現方法”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“Linux下SSH Session復制功能的實現方法”吧!

代碼如下:


Linux/mac下,在$HOME/.ssh/config中加入
Host *
ControlMaster auto
ControlPath <a>/tmp/ssh-%r@%h</a>

至此只要第一次SSH登錄輸入密碼,之后同個Hosts則免登。

配置文件分析

man ssh_config 5

代碼如下:


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, &lsquo;%l&rsquo; will be substituted by the
            local host name, &lsquo;%h&rsquo; will be substituted by the target host name, &lsquo;%p&rsquo; the port, and &lsquo;%r&rsquo; 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 為遠程機器的登錄名
%h 為遠程機器名

原理分析

嚴格地講,它并不是真正意義上的Session Copy,而只能說是共享Socket。
第一次登錄的時候,將Socket以文件的形式保存到:/tmp/ssh-%r@%h這個路徑
之后登錄的時候,一旦發現是同個主機,則復用這個Socket
故,一旦主進程強制退出(Ctrl+C),則其他SSH則被迫退出。

可以通過ssh -v參數,看debug信息驗證以上過程

到此,相信大家對“Linux下SSH Session復制功能的實現方法”有了更深的了解,不妨來實際操作一番吧!這里是億速云網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女