Skip to content

Instantly share code, notes, and snippets.

@jt6562
Created August 31, 2017 08:56
Show Gist options
  • Save jt6562/6e3359111814e3bff0fcd89e4bedb1d0 to your computer and use it in GitHub Desktop.
Save jt6562/6e3359111814e3bff0fcd89e4bedb1d0 to your computer and use it in GitHub Desktop.
ssh Permission denied (publickey).

今天遇到一个很诡异的事情。使用 ssh 远程登录测试一些脚本,使用的是公钥登录方式。脚本中有一些 apt 安装命令。但在删除安装的包后,无法使用另一个终端进行 ssh 登录。

好在原来的终端还在,否则连调试的机会都没有了。

分析/etc/ssh/sshd_config,没发现问题(本身也不会有问题)。最后看了一下login log /var/log/auth.log,如下:

Aug 31 16:48:11 debug010000002015 sshd[25395]: Server listening on 0.0.0.0 port 22.
Aug 31 16:48:37 debug010000002015 sshd[25407]: error: Could not load host key: /etc/ssh/ssh_host_ed25519_key
Aug 31 16:48:37 debug010000002015 sshd[25407]: User root not allowed because shell /usr/bin/zsh does not exist
Aug 31 16:48:37 debug010000002015 sshd[25407]: input_userauth_request: invalid user root [preauth]
Aug 31 16:48:37 debug010000002015 sshd[25407]: Connection closed by 192.168.205.123 port 47352 [preauth]

因为找不到shell,所以登录失败,omg!我在脚本中安装了zsh和oh-my-zsh,之后又删掉了,结果ssh罢工了!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment