#!/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传公钥到多台服务器
原创
©著作权归作者所有:来自51CTO博客作者小杨同学THY的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:jenkins需安装插件总结
下一篇:linux通过端口转发登陆ssh
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
运维总监让我管理 4 万台服务器,这可能吗?
运维工作
服务器 运维 硬件故障