yum install expect*
自動登入腳本如下:
#! /usr/bin/expect -f
set timeout 3
spawn ssh -p 22 [email protected]
expect {
"*yes/no" {send "yes\r";exp_continue}
}
expect "*password:"
send "123456789@#\r"
expect "root@*" {send "ls /opt\r"}
expect "root@*" {send "exit\r"}
interact
本文轉自 guowang327 51CTO部落格,原文連結:http://blog.51cto.com/guowang327/1795555,如需轉載請自行聯系原作者