帮助与文档

当前位置: 首页帮助中心云服务器 ECS > 

centos免密码使用密钥登录

centos免密码使用密钥登录
发布时间:2017-05-09

1、使用Key验证连接SSH

使用Key的登陆需要生成一对密钥,putty、secureCRT以及Xshell均有生成密钥的功能,本文以Xshell 5为例。

密码为密钥密码,如果不设置,只要拥有密钥就可以登录服务器,设置密码的话必须拥有密钥和密钥密码才能登录服务器.

4.jpg

2、开启sshd的密钥登录功能
# vi /etc/ssh/sshd_config
修改以下几处
PubkeyAuthentication yes
AuthorizedKeysFile
# service sshd restart

3、上传密钥文件至服务器并设置权限。
[root@centos1 ~]# mkdir /root/.ssh
[root@centos1 ~]# chmod 700 /root/.ssh/
[root@centos1 ~]# touch /root/.ssh/authorized_keys
[root@centos1 ~]# chmod 600 /root/.ssh/authorized_keys
然后将之前复制的公钥粘贴到/root/.ssh/authorized_keys下并重启SSH服务
[root@centos1 ~]# /etc/init.d/sshd restart
Stopping sshd:                 [  OK  ]
Starting sshd:   [  OK  ]


以上内容是否对您有帮助?