1.密钥分发脚本(一般是管理机进行分发,批量管理服务器)
#管理机创建公钥
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 [email protected]$i:~/.ssh/authorized_keys
sshpass -p $password ssh -o StrictHostKeyChecking=no $i "chmod 600 ~/.ssh/authorized_keys"
done
原文地址:http://blog.51cto.com/linux1991/2125583
时间: 2024-10-10 05:56:44