Jllin

expect 执行ssh-copy-id
vi deploy_ssh_key.exp#!/usr/bin/expect -f set timeout 2 ...
扫描右侧二维码阅读全文
14
2018/10

expect 执行ssh-copy-id

vi deploy_ssh_key.exp

#!/usr/bin/expect -f

set timeout 2
set ipaddress [lindex $argv 0]
set passwd "Pwd@123"

spawn ssh-copy-id "-p2222 mds@$ipaddress"

expect {
"yes/no" { send "yes\r";exp_continue }
"password:" { send "$passwd\r" }
}
expect "#"

for x incat ip.txt | awk '{print $1}';do ./deploy_ssh_key.exp $x;done

Last modification:October 14th, 2018 at 10:57 am
If you think my article is useful to you, please feel free to appreciate

Leave a Comment