[root@kvm19 ~]# 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:F9OoHjIT3jPlN95CnwEAKnrIQsySYaZMQOZU6wVpwsA root@kvm19.deyu.wang The key's randomart image is: +---[RSA 2048]----+ |XB.o. ... | |%E oo . + | |+*o...o = o | |o..o.o o + o . | |. +.. = S o + . | | . . = = + + o | | . o + | | . | | | +----[SHA256]-----+
id_rsa
私鑰及 id_rsa.pub
公鑰。
[root@kvm19 ~]# ll .ssh/ total 12 -rw-r--r--. 1 root root 401 Mar 2 10:32 authorized_keys -rw-------. 1 root root 1831 Mar 5 10:59 id_rsa -rw-r--r--. 1 root root 402 Mar 5 10:59 id_rsa.pub
id_rsa.pub
公鑰匯入到 kvm11,輸入密碼完成匯入。
[root@kvm19 ~]# ssh-copy-id kvm11.deyu.wang /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub" The authenticity of host 'kvm11.deyu.wang (192.168.122.11)' can't be established. ECDSA key fingerprint is SHA256:l6jIMoK+z82ydTlG8MKarNcUDLVSfjCRjWRzhGOtDNc. Are you sure you want to continue connecting (yes/no)? yes /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@kvm11.deyu.wang's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'kvm11.deyu.wang'" and check to make sure that only the key(s) you wanted were added.
[root@kvm19 ~]# ssh kvm11.deyu.wang Last login: Mon Mar 2 18:40:01 2020 from 192.168.122.1
[root@kvm11 ~]# exit logout Connection to kvm11.deyu.wang closed.