写好IP地址.自动创建互信
#!/bin/bash
#创建密钥对
rm -f ~/.ssh/id_dsa*
ssh-keygen -t dsa -f ~/.ssh/id_dsa -N "" &>/dev/null
#批量分发公钥
for ip in 31 61 90
do
echo "====hostname 172.16.1.$ip===="
sshpass -p123456 ssh-copy-id -i ~/.ssh/id_dsa.pub "-o StrictHostKeyChecking=yes 172.16.1.$ip" &>/dev/null
REVAL=$?
if [ $REVAL -eq 0 ]
then
echo -e "\033[32m host 172.16.1.$ip success!!!\033[0m"
echo
else
echo -e "\033[41;37m host 172.16.1.$ip fail!!! \033[0m"
echo
fi
done

最后修改:2019-11-06 19:20:07
© 著作权归作者所有
如果觉得我的文章对你有用,请随意赞赏
扫一扫支付

发表评论