為了方便管理多臺CENTOS,需要做多臺CENTOS之間的免賬號密碼登錄。
首先在機器A(IP:192.168.1.105)上生成RSA公鑰和私鑰。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
ssh-keygen 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:PHfparPgfNATE8fuG+vDlpOn9YZuH7DGO97CxcTHAq4 root@vip5.92k.xin The key's randomart image is: +---[RSA 2048]----+ | . | | . + | | = ... | | . o o..oo| | S..=o.o..| | .oEo+ oo | | .. ooXoo | | o .+.@=*.o| | ooo=+X++o| +----[SHA256]-----+ |
生成好了之后,我們需要同步到其他CENTOS機器上面
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
ssh-copy-id root@192.168.1.101 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub" The authenticity of host '192.168.1.101 (192.168.1.101)' can't be established. ECDSA key fingerprint is SHA256:Zjy1eMVh4Wm4ZbMv018a1DXMzcH7kYOFAQNnmT1ZJNo. ECDSA key fingerprint is MD5:98:46:fa:f9:2a:73:16:f0:12:5f:89:2a:d3:a9:93:c8. 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@192.168.1.101's password: (輸入root的密碼) Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'root@192.168.1.101'" and check to make sure that only the key(s) you wanted were added. |
好了,我們就可以在192.168.1.105 免密碼登錄到192.168.1.101 機器上面了。
但是我們現(xiàn)在是無法直接從192.168.1.101直接免密碼登錄192.168.1.105的。
如果需要實現(xiàn)192.168.1.101免密碼登錄192.168.1.105,需要同樣在192.168.1.101上做類似的同步操作。