我能够使用 root 用户的公钥设置 ssh 登录,并尝试对非 root 用户应用相同的逻辑。我试图解决这个问题是徒劳的。我在本地机器和远程服务器上都使用 centos。
这是我的远程服务器的 sshd_config 文件的要点,
RSAAuthentication yes
PublicKeyAuthentication yes
AuthorizedKeysFile /etc/ssh/user/authorized_keys
PasswordAuthentication no
UsePAM no
PermitRootLogin without-password
Run Code Online (Sandbox Code Playgroud)
我已将我的授权密钥文件从用户的家中移到 /etc/ssh/user/authorized_keys 中,因为我阅读了有关 centos 中的 home dir 加密的信息。
我还更改了与非 root 用户关联的所有文件/目录的所有权。
不确定我的配置中缺少哪个步骤,因为相同的配置对于 root 远程登录非常有效。