批量复制秘钥到服务器

### 最好安装一下git, 当然不安装也是OK的
pd="123@qwe"  # 统一的密码
  
list=$(cat inventory| grep -vE "^\[.*\]$"|awk '{print $1}'|grep -v "[a-z]")
for i in ${list};do
    {
    /usr/bin/sshpass -p${pd} ssh-copy-id -o StrictHostKeyChecking=no root@${i} >/dev/null  2>&1
    if [ $? == 0 ];then
        echo ${i} 秘钥copy成功
    else
        echo ${i} 秘钥copy失败
    fi
    }&
done
wait
  
### 单个复制
ssh-copy-id -o StrictHostKeyChecking=no root@192.168.1.1
posted @ 2022-02-07 18:44  つつつつつつ  阅读(92)  评论(0编辑  收藏  举报