#vi ssh-expect
===================
#!/usr/bin/expect
set timeout 60
spawn ssh -p 22 [lindex $argv 1]@[lindex $argv 0]
expect "yes/no" {
send "yes\r"
expect "*?assword" { send "[lindex $argv 2]\r" }
} "*?assword" { send "[lindex $argv 2]\r" }
expect "# " { send "ls -ltr\r" }
interact
===================
使用方法
#./ssh-expect IP root <密碼>
全站熱搜