sshpass实现批量基于ssh的key部署

#!/bin/bash
#
#********************************************************************
#Author: will
#QQ: 1052165684
#Date: 2021-01-16
#FileName: push_ssh_key.sh
#URL: www.xxx.com
#Description: The test script
#Copyright (C): 2021 All rights reserved
#********************************************************************
. /etc/init.d/functions
ip="
10.0.0.17
10.0.0.7
10.0.0.19"
[ -f /root/.ssh/id_rsa ] || ssh-keygen -P "" -t rsa -f /root/.ssh/id_rsa
rpm -q sshpass &> /dev/null || yum -y install sshpass &> /dev/null
export SSHPASS=123456

for i in $ip;do
sshpass -e ssh-copy-id -o StrictHostKeyChecking=no root@$i &> /dev/null && action "push key to $i is successufll"
done

 

posted @ 2021-01-16 11:31  浩浩呀  阅读(159)  评论(0)    收藏  举报