#!/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 yum -y install sshpass 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 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