批量免密操作:批量分发公钥
#!/bin/bash
rm -rf ~/.ssh/id_rsa*
ssh-keygen -f ~/.ssh/id_rsa -P "" > /dev/null 2>&1
SSH_PASS=123456
Key_PATH=~/.ssh/id_rsa.pub
# 如果是一段连续的值 {10..20}
for ip in 21 22
do
sshpass -p$SSH_PASS ssh-copy-id -i $Key_PATH "-o StrictHostKeyChecking=no" 10.0.0.$ip
done
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10