#管理机创建公钥
ssh-keygen -t dsa -P ‘‘ -f ~/.ssh/id_dsa >/dev/null 2>&1
#服务器密码统一,可以这样玩
password=123456
#分发密钥
for i in "192.168.10.10" "192.168.10.11" "192.168.10.12"
do
sshpass -p $password ssh -o StrictHostKeyChecking=no $i "mkdir -m 700 -p ~/.ssh/"
sshpass -p $password scp -o StrictHostKeyChecking=no ~/.ssh/id_dsa.pub root@$i:~/.ssh/authorized_keys
sshpass -p $password ssh -o StrictHostKeyChecking=no $i "chmod 600 ~/.ssh/authorized_keys"
done
原文:http://blog.51cto.com/linux1991/2125583