孤独是一种态度
expect
SSH的自动登录脚本
四 6th
#!/usr/bin/expect -f
set ipaddress [lindex $argv 0]
set passwd [lindex $argv 1]
set passwd1 [lindex $argv 2]
set timeout 30
spawn ssh -p 22 -c arcfour -o ConnectTimeout=30 root@$ipaddress "iptables-save && service iptables restart"
#spawn ssh -p 22 -c arcfour -o ConnectTimeout=30 root@$ipaddress "/etc/init.d/dnsmasq status"
#spawn rsync -avpur --progress -e "ssh -p 22 -c arcfour" /tmp/dnsmasq root@${ipaddress}:~/
expect {
"yes/no" { send "yes\r";exp_continue }
"password:" { send "$passwd\r" }
}
#expect "]*"
expect "password:"
send "$passwd1\r"
expect "]*"
原创文章,转载请注明: 转载自gjw_apparitor 博客
本文链接地址: SSH的自动登录脚本