阿里云设置密钥登录并禁止密码登录

参考:

https://www.alibabacloud.com/help/zh/doc-detail/51796.htm?spm=a2c63.p38356.879954.8.cf992580kK2PyO#concept-zzt-nl1-ydb

https://yq.aliyun.com/articles/518471

https://yq.aliyun.com/articles/604307

一、创建密钥对

填写信息后,会自动下载密钥,请自行保存好:

绑定密钥对

绑定后在控制面板进行重启

二、在xshell使用密钥进行登录

选择下载的pem文件,填写root用户名即可登录
登录后禁用密码进行登录:
1:修改/etc/ssh/sshd_config文件

找到:

RSAAuthentication yes  
PubkeyAuthentication yes  
AuthorizedKeysFile .ssh/authorized_keys

先把这3行命令改了,如果默认前面带了#,就把#给删掉,这里是让可以用密钥登录。

然后再找到:

PasswordAuthentication no

这里默认是yes,所以把改成no,就是禁止密码登录。

2:重启sshd服务

centos7 命令:

systemctl restart sshd.service
原文地址:https://www.cnblogs.com/flypig666/p/12887894.html