1.密钥分发脚本(一般是管理机进行分发,批量管理服务器)

#管理机创建公钥
ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa >/dev/null 2>&1

#服务器密码统一,可以这样玩
password=123456

#分发密钥
for i in $@
	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