C/C++教程

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

本文主要是介绍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
这篇关于centos7---批量添加密钥rsa认证-shell的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!