特别感谢阿干同学的邮件分享。
详细方法
复制代码代码如下:
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, ‘%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上通过证书的形式,可以实现免登录,没错。
对于静态密码,完全可以这么干;对于动态密码(口令的方式),则上述手段可以方便很多。
SSH,Session,复制功能
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
更新日志
- 艾什莉体模家今日份的COS:《鸣潮》守岸人 雪白香肩清纯而诱惑
- 微信积分商城进入方法,微信积分商城介绍
- 希诺宁进不进常驻说明,希诺宁角色分析
- 【原神】V5.0攻略 | 大型开图世界任务整合
- 群星.1990-细听锋芒(2014华星40金碟复刻版)【华星】【WAV+CUE】
- 郭婷筠.2024-爱你到底为啥物【福茂】【FLAC分轨】
- 王芷蕾.2010-仰望【丰华】【WAV+CUE】
- Ben Hum《Ben Hum (Acoustic Version)》[320K/MP3][108.48MB]
- Ben Hum《Ben Hum (Acoustic Version)》[FLAC/分轨][310.19MB]
- 徐璨宾《井底的蚯蚓》[320K/MP3][78.77MB]
- 碧蓝航线国庆金秋版本重磅上线 新玩法3D宿舍系统闪亮登场
- 自在西游自在服即将在10月1日开启 入驻即享豪礼满满
- 炉石传说最强术士卡组是哪个 术士最强天梯卡组推荐一览
- 炉石传说最强萨尔卡组是哪个 萨尔最强天梯卡组推荐一览
- 炉石传说最强潜行者卡组是哪个 潜行者最强天梯卡组推荐一览