linux expect自动登录ssh,ftp

来源:互联网 发布:java和golang 编辑:程序博客网 时间:2024/05/17 23:33

ref :http://blog.51yip.com/linux/1462.html

ref :http://www.cnblogs.com/mumuxinfei/p/3833874.html 【有expect的详细讲解】

这里实现了输入目标ip无需输入密码登陆机器的功能。

#!/usr/bin/expect -f #auto ssh login set timeout 30 set sshhost [lindex $argv 0] spawn ssh yourUserName@$sshhost expect {        "*yes/no" {send "yes\r"; exp_continue}         "*password*" {send "yourpassword\r"}} interact


0 0