1. 程式人生 > >使用expcet傳公鑰到多臺服務器

使用expcet傳公鑰到多臺服務器

pass tin continue var 服務 out 公鑰 expec pre

#!/usr/bin/expect if { $argc != 2 } { send_user "usage: expect ssh.exp ip\n" exit } #define var set ip [lindex $argv 0] set password [lindex $argv 1] spawn ssh-copy-id -i $ip expect { -timeout 2 "(yes/no)?" {send "yes\r";exp_continue} "*password" {send "$password\r"} timeout {puts "expect connect timeout,pls contact root;" return} } expect eof exit -onexit { send_user "root say good bye to you!\n" }

使用expcet傳公鑰到多臺服務器