我有一台运行 Linux 6.6.32、OpenSSH_9.7p1 和 OpenSSL 3.0.13(2024 年 1 月 30 日)的服务器。突然,重新启动后,当我从主笔记本电脑登录服务器时,服务器将不再接受我的 ED25519 密钥。在下文中,当我谈论服务器时,我指的是S ;当我谈论笔记本电脑时,我指的是L。
在命令行上从L登录到SPermission denied (publickey,keyboard-interactive)
会产生.如果我(暂时)允许在S上使用密码登录,则会提示我输入密码。
以下是我目前的所有发现:
- L上的默认 SSH 密钥的公钥肯定部署到了S中
/etc/ssh/authorized_keys.d/<username>
- 从L开始,我仍然可以使用相同的 ed25519 密钥 ssh 到具有相同 Linux 和 OpenSSH 版本的各种其他计算机,没有任何问题。
- 从另一台笔记本电脑上,我可以使用该笔记本电脑的默认 ED25519 密钥成功连接到S。
- 如果我在L上创建额外的 SSH 密钥并将相应的公钥部署到S,我可以使用以下命令成功连接:
ssh -i ~/.ssh/test_rsa_key user@S
ssh -i ~/.ssh/test_ed25519_key user@S
- 显式使用L (
ssh -i ~/.ssh/id_ed25519 user@S
)上的默认键不起作用 - 如果我将登录问题的密钥从L添加到S
~/.ssh/authorized_keys
上,它就可以了!但是我为用户提供的其他键如果位于.它也不必对订单做任何事情。/etc/ssh/authorized_keys.d/<username>
从Sjournalctl -u sshd
上我可以看到使用我的默认密钥尝试登录失败会导致:
May 29 16:25:15 S sshd[1836]: Connection closed by authenticating user <user> 81.201.150.231 port 49240 [preauth]
May 29 16:25:33 S sshd[1839]: error: PAM: Authentication failure for <user> from 81.201.150.231
此时,我不能说它是在客户端还是服务器端。我的客户端还使用版本 9.7p1 中的 openssh 包。
这是以下内容/etc/ssh/sshd_config
:
cat /etc/ssh/sshd_config
AuthorizedPrincipalsFile none
Ciphers [email protected],[email protected],[email protected],aes256-ctr,aes192-ctr,aes128-ctr
GatewayPorts no
KbdInteractiveAuthentication yes
KexAlgorithms [email protected],curve25519-sha256,[email protected],diffie-hellman-group-exchange-sha256
LogLevel INFO
Macs [email protected],[email protected],[email protected]
PasswordAuthentication no
PermitRootLogin without-password
PrintMotd no
StrictModes yes
UseDns no
UsePAM yes
X11Forwarding no
Banner none
AddressFamily any
Port 22
Subsystem sftp /nix/store/0g1s8yd0biawp32fl3i7kdbi219jx6aq-openssh-9.7p1/libexec/sftp-server
AuthorizedKeysFile %h/.ssh/authorized_keys /etc/ssh/authorized_keys.d/%u
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
我在 ssh、Linux 和 NixOS(我所有机器上的 Linux 发行版)方面拥有多年的经验。但在这种情况下,回滚到较旧的 NixOS 代/版本并没有改变任何内容。非常令人困惑 - 特别是因为只有这个非常有限的情况不再起作用!