注):主机需安装pssh、expect相关命令;
一、由中心主机生成公钥并批量传输至各节点
中心主机以root执行ssh-keygen -t rsa
在/root/.ssh/下生成id_rsa(私钥); id_rsa.pub(公钥);
cat /root/.ssh/id_rsa.pub > /tmp/authorized_keys //备份并授权chmod 600
通过shell传输公钥至各节点(scp.sh&info.txt):
//cat scp.sh (scp shell)
#!/bin/bash
if [ $# -ne 1 ] ;then
echo "need server info file!"
exit 1
fi
while read line