用expect脚本实现。
#!/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
这里[lindex $argv 0], [lindex $argv 1], [lindex $argv 2], [lindex $argv 3] 分别代表着4个参数。
将这个文件命名为: item2login.sh 复制到 /usr/local/bin 就可以了。 然后在iTerm2里面配置。
command+o 唤醒编辑列表,在general中,send text at start 输入:
item2login.sh 22 root 192.168.1.1 password
脚本 端口号 用户名 服务器地址 密码 一定要一一对应
如果要新增,只需要更改后面的几个参数即可,不必重新配置文件。