centos服务器配置密钥登录

1、生成密钥文件

ssh-keygen -t rsa    #生成密钥

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa): 密钥生成地址

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.

chmod -R 700 /root/.ssh/    #设置权限,仅当前用户可以读写

下载该文件下的id_rsa私钥文件

2、设置ssh只能密钥登录

vim /etc/ssh/sshd_config  #编辑ssh配置文件

PasswordAuthentication no  #关闭密码登录

systemctl restart sshd  #重启服务

注意:一定要在确认密钥文件可以使用后再关闭密码登录

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

友情链接更多精彩内容