1. 检查linux的ssh配置文件/etc/ssh/sshd_config,找到如下配置是否存在并且未被注释:

PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
  1. 放开注释后重启ssh服务

sudo systemctl restart sshd
  1. 检查~/.ssh/authorized_keys权限是否正确

chmod 600 ~/.ssh/authorized_key
  1. 检查本地私钥文件~/.ssh/id_rsa权限是否正确

chmod 600 ~/.ssh/id_rsa