服务器列表文件:
[root@ph ~]# cat serverlist.txt
172.16.0.15
172.16.0.16
免密脚本:
[root@ph ~]# cat nopasswd.sh
#!/bin/bash
current=/root
serverlist=`cat $current/serverlist.txt`
mkdir -p /root/.ssh
ssh-keygen -t rsa -P ''
for ip in $serverlist
do
echo "$ip Need to configure password free."
scp /root/.ssh/id_rsa.pub root@$ip:/root/.ssh/authorized_keys
done