执行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]-----+
此时.ssh
目录会多出id_rsa
、id_rsa.pub
两个文件.
将公钥文件复制到远程设备中
# ssh-copy-id root@192.168.xx.xxx
此时再次通过ssh
连接远程设备就不需要密码
Nelson:~ Nelson$ ssh root@192.168.10.131
Nelson-iPad:~ root#