centos7---批量添加密钥rsa认证-shell

[root@base7 media]# cat ssh.sh #!/bin/bash #env passwd=123456
#ssh-keygen -t rsa -P "" -f /root/.ssh/id_rsa yum install -y expect
#for i in `cat ip.txt`;do #mkdir ip.txt
#name=(node-61 node-62 node-63) name=(node-61 node-62 node-63) for i in ${name[@]}; do   expect -c "   spawn ssh-copy-id -i /root/.ssh/id_rsa.pub root@$i   expect {     \"*yes/no*\" {send \"yes\r\"; exp_continue}     \"*password*\" {send \"${passwd}\r\"; exp_continue}     \"*Password*\" {send \"${passwd}\r\";}   }" done
#no rsa #!/bin/bash #env passwd=123456
yum install -y sshpass #name=(node-61 node-62 node-63) name=(node-61 node-62 node-63) for i in ${name[@]}; do   sshpass -p ${passwd} ssh -o "StrictHostKeyChecking no" systemusers@${i} "sudo /usr/sbin/shutdown -h now" done
上一篇:Grafana 未授权任意文件读取漏洞


下一篇:Linux之sed与awk及LAMP网站架构