话不多说上干货
查询ssh证书
cat ~/.ssh/authorized_keys
如果该文件不存在
在root目录下
创建文件夹
mkdir .ssh
去生成一个文件即可
sudo touch ~/.ssh/authorized_keys
如果存在,新增自己的证书
vim ~/.ssh/authorized_keys
修改ssh登录配置
vim /etc/ssh/sshd_config
设置 SSH,打开密钥登录功能,编辑 /etc/ssh/sshd_config 文件,进行如下设置
RSAAuthentication yes
PubkeyAuthentication yes
另外,请留意 root 用户能否通过 SSH 登录
PermitRootLogin yes
关掉密码登录进行证书登录测试,没问题后,再禁用密码登录:(建议留一个已经登录的窗口,避免配置出现问题后出现无法登录的情况)
PasswordAuthentication no
重启sshd服务
systemctl restart sshd.service
启动
systemctl start sshd.service
查询状态
systemctl status sshd.service