美文网首页
iterm2 保存多个ssh账号密码

iterm2 保存多个ssh账号密码

作者: xiaoer0128 | 来源:发表于2019-04-05 18:28 被阅读0次

习惯windows下ssh管理工具xshell或者secureCRT,切换到mac osx中也想使用类似的管理工具方便快速连接。iterm2是个不错的工具至少看起来比较漂亮,并且支持自定义插件,是个不错的免费开源工具。
接下来就设置iterm2支持ssh不要输入密码登录

第一步: 创建shell命令文件,具体的路径自己放置(记得加上权限哦),示例:/Users/yuml/bin/iterm2login.sh

#!/usr/bin/expect

set timeout 30
spawn ssh -p [lindex $argv 0] [lindex $argv 1]@[lindex $argv 2]
expect {
        "(yes/no)?"
        {send "yes\n";exp_continue}
        "password:"
        {send "[lindex $argv 3]\n"}
}
interact

shell文件是expect语言脚本,可以自动和网络交互,基本原理就是解析ssh的命令文本返回,根据文本内容匹配,执行对应的操作,send就是模拟人工输入。

第二步: 设置iterm2,在profiles中建立一个新profile,配置如192.168.100.127中描述填写。

image
Name: 填写便于记忆的名称
Login shell -> Send text at start: /Users/yuml/bin/iterm2login.sh 22 root 192.168.100.127 you password

**第三步:** 运行profile, 在iterm2的顶部工具栏有一栏`Profiles`,就可以看到对应的profle,双击就可以了。

相关文章

网友评论

      本文标题:iterm2 保存多个ssh账号密码

      本文链接:https://www.haomeiwen.com/subject/nsjkiqtx.html