您的位置:首页 > 运维架构 > Linux

linux expect自动登录ssh,ftp

2015-05-13 10:17 441 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: