#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 <密碼>

 

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 slinbody 的頭像
    slinbody

    495884965

    slinbody 發表在 痞客邦 留言(0) 人氣()