expect自動輸入密碼

安裝軟件包:yum install expect


腳本功能,從服務器做信任到192.168.101.75-99的IP地址的服務器。


腳本內容:

#!/usr/bin/expect

set timeout 60

for {set i 75} {$i<100} {incr i} {

        spawn ssh-copy-id [email protected].$i

        expect {

                "(yes/no)?"

                {

                        send "yes\n"

                        expect "*assword:" {send "myself_password\n"}

                }

                "*assword:"

                {

                        send "myself_password\n"

                }

        }

}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章