创建 login.sh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| #!/usr/bin/expect set user root
set ipaddress xxx.xxx.xxx.xxx
set passwd xxxxxxx
set timeout 30
spawn ssh $user@$ipaddress
expect { "*password:" { send "$passwd\r" }
"yes/no" { send "yes\r";exp_continue }
}
interact
|
使用: 终端输入 expect login.sh
参考:https://blog.csdn.net/u010397980/article/details/82078319