參考:
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