在CentOS上生成SSH密钥对的步骤如下:
ssh-keygen
命令打开终端:
Ctrl + Alt + T
打开终端。运行ssh-keygen
命令:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
-t rsa
指定使用RSA算法。-b 4096
指定密钥长度为4096位,提供更高的安全性。-C "your_email@example.com"
添加一个注释,通常是你的电子邮件地址,方便识别密钥。选择保存位置和文件名:
~/.ssh/id_rsa
(私钥)和 ~/.ssh/id_rsa.pub
(公钥)。设置密码短语(可选):
确认密钥生成:
Generating public/private rsa key pair.
Enter file in which to save the key (/home/your_username/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
查看生成的密钥:
cat ~/.ssh/id_rsa.pub
~/.ssh/authorized_keys
文件中,以便进行SSH无密码登录。如果你更喜欢使用图形界面,可以按照以下步骤操作:
打开“系统设置”:
进入“用户和群组”设置:
点击“SSH密钥”选项卡:
生成新的SSH密钥对:
查看和管理密钥:
sshd_config
文件中的 PubkeyAuthentication
设置为 yes
。通过以上步骤,你应该能够在CentOS上成功生成SSH密钥对,并将其用于SSH无密码登录或其他安全相关的用途。