MAC && Linux terminal session clone
背景
本人使用的是mac,terminal配置的是iterm2,相信许多公司和我司一样登录dev/beta/prod机器的时候需要先
通过跳板机登录。而且往往都会为每一位开发配置一个token,动态的产生一个6位的数字串,用来作为登录密码。
因为每次登录都需要输入token串,对于我这种懒鬼来说是一件非常麻烦的事情,本文章就讲解了如何配置来实现类似于
secureCRT
一样的session clone功能
操作步骤
-
在~目录下的
.ssh
文件夹冲创建一个config
文件, -
文件内容输入:
host * ControlMaster auto ControlPath ~/.ssh/master-%r@%h:%p
-
这样的话,当登录第一次登录跳板机器的时候,和往常一样,但是第二次登录同样的跳板机的时候,就不需要输入token了。
这样可以在一定程度上减少输入token的次数。
如果你细心的话,你在~/.ssh/目录下发现master-*的sock文件。它记录了你目前登录到的机器,这样的话,你登录同样的机器就会重用同一个链接了。