羡慕Windows下secureCRT的Session Copy功能,一直在寻找Linux下类似的软件,殊不知SSH本身就支持此功能。
特别感谢阿干同学的邮件分享。

详细方法

1
2
3
4
Linux/mac下,在$HOME/.ssh/config中加入
Host *
ControlMaster auto
ControlPath /tmp/ssh-%r@%h

至此只要第一次SSH登录输入密码,之后同个Hosts则免登。

配置文件分析

man ssh_config 5

1
2
3
4
5
6
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上通过证书的形式,可以实现免登录,没错。
对于静态密码,完全可以这么干;对于动态密码(口令的方式),则上述手段可以方便很多。

http://www.cnblogs.com/killkill/archive/2012/05/22/2513192.html

Linux下SSH Session复制的更多相关文章

  1. linux下文件的复制、移动与删除

    linux下文件的复制.移动与删除命令为:cp,mv,rm 一.文件复制命令cp     命令格式:cp [-adfilprsu] 源文件(source) 目标文件(destination)      ...

  2. Linux下SSH免密码登录

    转自:http://haitao.iteye.com/blog/1744272 ssh配置 主机A:10.0.5.199 主机B:10.0.5.198 需要配置主机A无密码登录主机A,主机B 先确保所 ...

  3. Linux下SSH+Firefox

    Linux下SSH+Firefox 简明FQ攻略 FQ的软件有很多,楼主原来在Windows下用过Tor(洋葱头).Puff.freegate等,一般只需要打开FQ软件,简单的设置后就可以FQ浏览了. ...

  4. linux下ssh端口的修改和登录

    linux下ssh端口的修改和登录 首先修改配置文件 vi /etc/ssh/sshd_config 找到#Port 22一段,这里是标识默认使用22端口,添加如下一行: Port 50000 然后保 ...

  5. 学习笔记12—linux下文件的复制、移动与删除

    查看centOS 版本     cat /etc/redhat-release 1,复制粘贴文件 cp  [选项]  源文件或目录  目标文件或目录 2,剪切粘贴文件 mv [选项]  源文件或目录 ...

  6. Linux 下 SSH 远程超时解决方案

    Linux 下 SSH 远程超时解决方案 今天突然看到一个问题说是如何解决SSH远程超时的问题. 找了一点资料.用于解决这个需求~ 第一种:OpenSSH 配置文件设置 位于112行的 "C ...

  7. 在linux下的使用复制命令cp,不让出现“overwrite”(文件覆盖)提示的方法。(转)

    在linux下的使用复制命令cp,不让出现“overwrite”(文件覆盖)提示的方法. 一般我们在使用cp命令时加上-f选项,希望不让出现“overwrite”的提示(文件覆盖的提示).如:# cp ...

  8. 解决Linux下SSH超时自动断开

    title: 解决Linux下SSH超时自动断开 comments: false date: 2019-08-19 19:22:55 description: Linux 下 SSH 超时自动断开?? ...

  9. linux下ssh远程登录/scp远程复制文件/rsync远程同步命令的自动登录

    最近需要写一个脚本备份各个服务器上的程序到一个指定服务器上,本来以为查查rsync命令的使用321就能搞定,结果rsync命令要支持自动登 录还是要配置服务和参数,又不确定网上说的配置的行不行,因为都 ...

随机推荐

  1. UVA 10652 Board Wrapping(凸包)

    The small sawmill in Mission, British Columbia, hasdeveloped a brand new way of packaging boards for ...

  2. ceph操作相关命令整合

    ceph基本操作: /etc/init.d/ceph -a start/stop //即在所有节点上执行 单个操作: start/stop ceph-osd id={id} start/stop ce ...

  3. BestCoder Round #50 (div.1) 1003 The mook jong (HDU OJ 5366) 规律递推

    题目:Click here 题意:bestcoder 上面有中文题目 分析:令f[i]为最后一个木人桩摆放在i位置的方案,令s[i]为f[i]的前缀和.很容易就能想到f[i]=s[i-3]+1,s[i ...

  4. VMware-Workstation安装在ubuntu15.04(内核3.19)

    安装的最新版的linux15.04 安装VMware-Workstation11,运行gui程序的时候出现,VMware Kernel Module Update的提示窗口, 说是要更新vmnet-d ...

  5. json接口相关(建议结合JFinal框架)

    /** * */ package net.wicp.wvqusrtg; import java.util.HashMap; import net.sf.json.JSONArray; import n ...

  6. javascript 学习随笔3

    <html> <head> <script type="text/javascript"> function startTime() { var ...

  7. Android访问网络(可以正常使用)

    以下是MainActiviy.java,有必要的注释,里面用到了handler,以及线程,workThread如何更新mainThread才能够更新的内容. package com.wyl.httpt ...

  8. oracle_SQL中ROWID与ROWNUM的使用(转)

    转自:http://www.360doc.com/content/12/0802/11/219024_227802569.shtml rownum: ROWNUM是对结果集加的一个伪列, 即先查到结果 ...

  9. PHP MYSQL数据字典

    <?php /** * 生成mysql数据字典 */ header ( "Content-type: text/html; charset=utf-8" ); // 配置数据 ...

  10. IOS某个ViewController禁止自动旋转

    IOS屏幕自动旋转,强制横竖屏方法: - (BOOL)shouldAutorotate { return YES; } - (NSUInteger)supportedInterfaceOrientat ...