gol*_*cks 6 key-authentication sshd
我正在设置远程服务器。该sshd配置为仅使用公钥。远程机器上有两个相同的帐户.ssh/authorized_keys,因此我可以使用相同的密钥登录。两者之一是 root,当我尝试时:
ssh -i /path/to/privatekey root@remote.serverRun Code Online (Sandbox Code Playgroud)
我进去,没问题。但是,当我尝试其他(非特权)用户时:
ssh -i /path/to/privatekey bob@remote.serverRun Code Online (Sandbox Code Playgroud)
它失败。 -v显示:
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering DSA public key: /path/to/privatekey
debug1: Authentications that can continue: publickey
debug1: Trying private key: /path/to/privatekey
**debug1: key_parse_private_pem: PEM_read_PrivateKey failed**
debug1: read PEM private key done: type <unknown>
Enter passphrase for key '/path/to/privatekey':
Run Code Online (Sandbox Code Playgroud)
成功登录 root@server 时不会出现星号行。这也很奇怪,因为ssh-agent已经有了这个密钥的密码;我没有被问到 root@server 登录名。失败的 bob@server 登录结束:
debug1: read PEM private key done: type DSA
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).
Run Code Online (Sandbox Code Playgroud)
权限等/home/bob/.ssh是正确的[但在 .ssh 目录上没有执行位,请参阅评论]。这实际上是系统升级/重新安装,我有一个/etc包括sshd配置在内的以前的备份。我没有改变任何东西(虽然当我允许密码验证时,bob 可以进入),这就是我之前通过 git 使用系统的方式——所以我有一堆项目git remoteID 被键入以通过 ssh 使用 bob@server ,并且不想更改这些,因为我无法sshd像以前那样工作...
请确认以下事项:
.ssh目录的权限是 700。为了进入目录,需要目录的执行权限。
authorized_keys文件的权限必须是 600。
作为系统管理员,我也遇到过这种问题。