大网数据广告活动
服务器运维问答

OpenSSH server reporting conflicting authentication methods

· 52CE 我爱测

We're having problems connecting to a server using a password over SSH. What makes the situation strange is that I see contradictory authentication methods available: $ ssh -v [email omitted] -o PreferredAuthentications=password …

问题原文

原帖链接 · BoppreH · CC BY-SA 4.0

We're having problems connecting to a server using a password over SSH. What makes the situation strange is that I see contradictory authentication methods available:

$ ssh -v [email omitted] -o PreferredAuthentications=password
OpenSSH_7.9p1, OpenSSL 1.1.1a  20 Nov 2018
debug1: Connecting to example.com [1.2.3.4] port 22.
debug1: Connection established.
debug1: Local version string SSH-2.0-OpenSSH_7.9
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4
debug1: match: OpenSSH_7.4 pat OpenSSH_7.0*,OpenSSH_7.1*,OpenSSH_7.2*,OpenSSH_7.3*,OpenSSH_7.4*,OpenSSH_7.5*,OpenSSH_7.6*,OpenSSH_7.7* compat 0x04000002
[...]
debug1: Authentications that can continue: publickey,password <<< HERE
debug1: Next authentication method: password
[email omitted]'s password:
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.
[email omitted]'s password:
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.
[email omitted]'s password:
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
[email omitted]: Permission denied (publickey). <<< HERE

My understanding is that the two marked lines should show matching authentication methods, so either

debug1: Authentications that can continue: publickey
[...]
[email omitted]: Permission denied (publickey).

or

debug1: Authentications that can continue: publickey,password
[...]
[email omitted]: Permission denied (publickey,password).

See for example other logs with matching authentication methods here, here, and here.

Is this a sign that something is wrong, or a harmless variation?


Edit:

1: I'm not looking for help on how to setup the authentication methods on sshd_config, this has already been done.

2: This is probably not caused by entering a wrong password, because I just tested on a personal server and the methods still match:

$ ssh -v [email omitted] -o PreferredAuthentications=password
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password <<< HERE
debug1: Next authentication method: password
[email omitted]'s password:
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.
[email omitted]'s password:
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.
[email omitted]'s password:
debug1: Authentications that can continue: publickey,password
debug1: No more authentication methods to try.
[email omitted]: Permission denied (publickey,password). <<< HERE

3: It's also not an incorrect username, or the -o PreferredAuthentications=password flag, my personal server still replies with Permission denied (publickey,password). on those scenarios.

已采纳解答

原帖链接 · SYNStealth · CC BY-SA 4.0

I think what's happening in your debug is that after your permitted attempts to authenticate fail, the server or your client are telling you that no more password attempts will be permitted and that the client must try the public key instead.

So, either your username or password were entered improperly (or the user is not permitted to SSH). Additionally, it did not like your public key at the end. If this issue persists and you believe that you are entering the correct credentials- you may either:

  1. Have hit the limit of Authentication requests.
  2. Have a misconfigured permission on your server. Please refer to the standard SSH file permissions listed in Nicolas Carey's answer here.

To solve the first issue, you will need to restart your sshd process on the server AND correct your .ssh directories permissions (along with authorized_keys in particular).

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2022-08-30)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。