#!/usr/bin/expect
set user user
set passwd "password"
if {$argc == 0} {
set host 10.8.8.8
} else {
set host [lindex $argv 0]
}
spawn ssh -p22 -o StrictHostKeyChecking=no $user@$host
expect {
"*yes/no" { send "yes\r"; exp_continue }
"*password:" { send "$passwd\r" }
"*#" { send "\r" }
}
expect "*#"
interact
使用expect自动登陆linux系统
最新推荐文章于 2024-04-30 17:02:38 发布