iOS ssh无密码登录

818 阅读1分钟

执行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_rsaid_rsa.pub两个文件.

F6045D8F-10DD-4165-B657-501D0685B7D7.png

将公钥文件复制到远程设备中

# ssh-copy-id root@192.168.xx.xxx

此时再次通过ssh连接远程设备就不需要密码

Nelson:~ Nelson$ ssh root@192.168.10.131
Nelson-iPad:~ root#