1. ssh-keygen -t rsa -P 'xiaoyuer' -- 生成秘钥 建立密钥对
    2. cd .ssh
    3. cat id_rsa.pub >> authorized_keys
    4. chmod 600 authorized_keys
    5. chmod 700 ~/.ssh
    6. -- /etc/ssh/sshd_config
    7. RSAAuthentication yes
    8. PubkeyAuthentication yes
    9. 另外,请留意 root 用户能否通过 SSH 登录,默认为yes
    10. PermitRootLogin yes
    11. 当我们完成全部设置并以密钥方式登录成功后,可以禁用密码登录。这里我们先不禁用,先允许密码登陆
    12. PasswordAuthentication yes
    13. 最后,重启 SSH 服务:
    14. service sshd restart

    image.png
    xshell
    image.png