新建文件: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
/Users/Macbook/Documents/SysSoftware/shell/iterm2login.sh 22 parallels 10.211.55.15 778521ab*
/Users/Macbook/Documents/SysSoftware/shell/iterm2login.sh 22 root 10.211.55.15 778521ab*
修改权限
chmod a+x /Users/Macbook/Documents/SysSoftware/shell/iterm2login.sh