让mac的终端实现克隆会话功能

win上的securecrt和xshell都支持克隆回话,这样ssh到别的主机就不需要每次都输入密码。mac版的securecrt非常难用,网上找到方法可以让mac自带的终端实现克隆会话的功能,如下。

cd ~/.ssh
touch config

在config文件中写入下面的内容:

Host *
    ControlMaster auto
    ControlPath ~/.ssh/%h-%p-%r
    ControlPersist yes

第一次登陆输入密码后,第二次登陆就不需要密码了。每次登陆,会在~/.ssh中建立一个soket文件,下次用相同用户名,端口,主机名进行连接就会自动复用