设置iterm2可以保存ssh用户密码

主要思想是在iterm2的profile里自动执行命令,需要有个脚本模拟用户登陆步骤

脚本

第1个参数是用户名,第2个参数是host,第3个参数是密码。

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

注意:保存到自己设置到一个目录里,记得设置执行权限: chmod 755 文件名.sh

配置iterm2

  • 新建profile
  • 在command里设置:文件绝对路径 登陆用户名 host 密码 (这里要注意是空格分割)
posted @ 2020-01-02 19:43  yeevan  阅读(1438)  评论(0编辑  收藏  举报