[root@inode ~]# ssh-keygen -t rsa
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:
26:9f:d3:b6:82:9c:6e:76:57:dc:d7:1d:1d:86:91:c2 root@inode
The key's randomart image is:
+--[ RSA 2048]----+
| . .+ |
| E o o |
| . . o|
| ..|
| . S . . +|
| + o o . +|
| . o+ o. . |
| * oo.. |
| +.. o. |
+-----------------+
[root@inode ~]# cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
[root@inode ~]# chmod 600 /root/.ssh/authorized_keys
[root@inode ~]# chmod 700 /root/.ssh/
[root@inode ~]# ll .ssh
总用量 12
-rw-------. 1 root root 392 1月 6 00:51 authorized_keys
-rw-------. 1 root root 1675 1月 6 00:51 id_rsa
-rw-r--r--. 1 root root 392 1月 6 00:51 id_rsa.pub
[root@inode ~]#
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:
26:9f:d3:b6:82:9c:6e:76:57:dc:d7:1d:1d:86:91:c2 root@inode
The key's randomart image is:
+--[ RSA 2048]----+
| . .+ |
| E o o |
| . . o|
| ..|
| . S . . +|
| + o o . +|
| . o+ o. . |
| * oo.. |
| +.. o. |
+-----------------+
[root@inode ~]# cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
[root@inode ~]# chmod 600 /root/.ssh/authorized_keys
[root@inode ~]# chmod 700 /root/.ssh/
[root@inode ~]# ll .ssh
总用量 12
-rw-------. 1 root root 392 1月 6 00:51 authorized_keys
-rw-------. 1 root root 1675 1月 6 00:51 id_rsa
-rw-r--r--. 1 root root 392 1月 6 00:51 id_rsa.pub
[root@inode ~]#
本文详细介绍了如何使用ssh-keygen命令生成SSH密钥对,并进行必要的文件权限设置,以便实现无密码登录。通过本教程,读者可以学会创建私钥和公钥,将公钥添加到授权密钥文件中,并确保所有文件的正确权限设置。

3万+

被折叠的 条评论
为什么被折叠?



