[root@k8s-master ~]# ssh-
ssh-add ssh-agent ssh-copy-id ssh-keygen ssh-keyscan
#生成免密密钥
[root@k8s-master ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
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:QdM7NW3JpWzBAekd9xJ7hWeeoihS2LCDM0F9wWCnV5g root@k8s-master
The key's randomart image is:
+---[RSA 2048]----+
| ...ooo*o .*o=.|
| ..ooE... +.Xo=|
| o.*.. + ++O+|
| + +.o .o .o+.+|
| o o S ... .o |
| . . . . |
| . . |
| |
| |
+----[SHA256]-----+
#把免密号发过去
[root@k8s-master ~]# ssh-copy-id ip地址
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@ip地址's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'ip地址'"
and check to make sure that only the key(s) you wanted were added.