# 配置免密 (二选一)
ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:nK3CqSGRBGZfrE5rncPEQ2eU/Gq6dttYMLIiesXHyO8 root@ceph-01
The key's randomart image is:
+---[RSA 3072]----+
|.o ..o.. |
|o.. .o = |
| ..+ o . |
| . + + . + |
| =o=+ooS . |
| ==*=+o. |
| .oo.+B .. |
|. o..=.o+ |
|.. ooEo.. |
+----[SHA256]-----+
# 将免密传输到各个主机上
ssh-copy-id root@node1
ssh-copy-id root@node2
ssh-copy-id root@node3
# 使用懒人方式配置免密 (二选一)
yum install -y sshpass
ssh-keygen -f /root/.ssh/id_rsa -P ''
export IP="node1 node2 node3"
export SSHPASS=123123
for HOST in $IP;do
sshpass -e ssh-copy-id -o StrictHostKeyChecking=no $HOST
done