国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Linux > 正文

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

2020-05-27 12:52:42
字體:
來源:轉載
供稿:網友

   特別感謝阿干同學的郵件分享。

  詳細方法

  代碼如下:

  Linux/mac下,在$HOME/.ssh/config中加入

  Host *

  ControlMaster auto

  ControlPath /tmp/ssh-%r@%h

  至此只要第一次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, ‘%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 為遠程機器的登錄名

  %h 為遠程機器名

  原理分析

  嚴格地講,它并不是真正意義上的Session Copy,而只能說是共享Socket。

  第一次登錄的時候,將Socket以文件的形式保存到:/tmp/ssh-%r@%h這個路徑

  之后登錄的時候,一旦發現是同個主機,則復用這個Socket

  故,一旦主進程強制退出(Ctrl+C),則其他SSH則被迫退出。

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

  備注

  有同學說在linux上通過證書的形式,可以實現免登錄,沒錯。

  對于靜態密碼,完全可以這么干;對于動態密碼(口令的方式),則上述手段可以方便很多。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 巴楚县| 广南县| 大同县| 嵊州市| 汝城县| 新宁县| 江口县| 金寨县| 搜索| 韶山市| 大兴区| 额尔古纳市| 五原县| 克山县| 巴东县| 黔江区| 瑞丽市| 古浪县| 吉木乃县| 杭州市| 前郭尔| 麦盖提县| 资源县| 高邮市| 高阳县| 玉林市| 社会| 青州市| 西青区| 巫溪县| 大足县| 湖南省| 浪卡子县| 沅陵县| 大悟县| 乐亭县| 团风县| 彭山县| 磴口县| 岢岚县| 九台市|