mac shell脚本自动登陆远程服务器

省去每次都要输入地址密码的麻烦
198login.sh

#!/usr/bin/expect -f
set user "name"
set host "xxx.xxx.xxx.xxx"
set password "123456"
set timeout -1

spawn ssh $user@$host
expect "*assword:*"
send "$password\r"
interact
expect eof

执行

chmod +x 198login.sh
./198login.sh

你可能感兴趣的:(mac shell脚本自动登陆远程服务器)