執(zhí)行ssh-keygen -t rsa
命令行生成公鑰浅萧、密鑰,需要交互輸入的直接回車鍵
Nelson:~ Nelson$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/freegeek/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/freegeek/.ssh/id_rsa.
Your public key has been saved in /Users/freegeek/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:8apTQO4+0lrrLaAOj+rDNEvBn4RobR6NK4dLpz1B0ck Nelson@Nelson.local
The key's randomart image is:
+---[RSA 2048]----+
| o . |
| . E. |
|o o +o . |
|.= B .o o |
|. O +. .S . |
| B O. . .. |
|* X..+... |
| X.o..*+ |
|=o+ o+++. |
+----[SHA256]-----+
此時(shí).ssh
目錄會(huì)多出id_rsa
参咙、id_rsa.pub
兩個(gè)文件.
將公鑰文件復(fù)制到遠(yuǎn)程設(shè)備中
# ssh-copy-id root@192.168.xx.xxx
此時(shí)再次通過ssh
連接遠(yuǎn)程設(shè)備就不需要密碼
Nelson:~ Nelson$ ssh root@192.168.10.131
Nelson-iPad:~ root#