安装工具
brew install expect
brew install spawn-fcgi
登录脚本, 替换ip与密码
#!/usr/bin/expect
set user root
set ipaddress 120.76.xx.xx
set passwd xxx
set timeout 30
spawn ssh $user@$ipaddress
expect {
"*password:" { send "$passwd\r" }
"yes/no" { send "yes\r";exp_continue }
}
interact
执行登录,【不是bash,sh】
expect login.sh
/usr/bin/expect login.sh