expect 执行ssh-copy-id
Posted mulinux
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了expect 执行ssh-copy-id相关的知识,希望对你有一定的参考价值。
vi deploy_ssh_key.exp
#!/usr/bin/expect -f set timeout 2 set ipaddress [lindex $argv 0] set passwd "[email protected]" spawn ssh-copy-id "-p2222 [email protected]$ipaddress" expect { "yes/no" { send "yes\r";exp_continue } "password:" { send "$passwd\r" } } expect "#"
for x in `cat ip.txt | awk ‘{print $1}‘`;do ./deploy_ssh_key.exp $x;done
以上是关于expect 执行ssh-copy-id的主要内容,如果未能解决你的问题,请参考以下文章
Linux免密大法好 ssh-copy-id 和 expect 免交互输入脚本
shell脚本实现ssh-copy-id批量自动发送公钥到远程主机
报错:✘ http://eslint.org/docs/rules/indent Expected indentation of 0 s paces but found 2(代码片段
报错:✘ http://eslint.org/docs/rules/indent Expected indentation of 0 s paces but found 2(代码片段