无法使用 ed22519 进行 ssh,尽管客户端和服务器都支持它

无法使用 ed22519 进行 ssh,尽管客户端和服务器都支持它

客户端和服务器操作系统/版本:Ubuntu 22.04.1

通过密码登录到该框,将我的 id_ed25519.pub 添加到用户的 authorized_keys。然而,服务器似乎拒绝接受密钥。

调试 ssh -v (客户端):

debug1: Skipping ssh-ed25519 key /home/x/.ssh/id_ed25519 - corresponding algo not in PubkeyAcceptedAlgorithms

sshd -T 输出(服务器):

pubkeyacceptedalgorithms ...,ssh-ed25519,...

ssh -Q 密钥(客户端):

...
ssh-ed25519
...

我特意将PubkeyAcceptedAlgorithms +ssh-ed25519和添加PubkeyAuthentication yes到 sshd_config 并执行了此操作systemctl restart sshd,但是这没有任何效果。

尽管客户端和服务器都应该接受这个密钥,但可能是什么原因导致使用该密钥失败?

答案1

您可以尝试此配置吗Mozilla 安全

# Supported HostKey algorithms by order of preference.
HostKey /etc/ssh/ssh_host_ed25519_key
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key

KexAlgorithms [email protected],ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group-exchange-sha256

Ciphers [email protected],[email protected],[email protected],aes256-ctr,aes192-ctr,aes128-ctr

MACs [email protected],[email protected],[email protected],hmac-sha2-512,hmac-sha2-256,[email protected]

# Password based logins are disabled - only public key based logins are allowed.
AuthenticationMethods publickey

# LogLevel VERBOSE logs user's key fingerprint on login. Needed to have a clear audit track of which key was using to log in.
LogLevel VERBOSE

# Log sftp level file access (read/write/etc.) that would not be easily logged otherwise.
Subsystem sftp  /usr/lib/ssh/sftp-server -f AUTHPRIV -l INFO

# Root login is not allowed for auditing reasons. This is because it's difficult to track which process belongs to which root user:
#
# On Linux, user sessions are tracking using a kernel-side session id, however, this session id is not recorded by OpenSSH.
# Additionally, only tools such as systemd and auditd record the process session id.
# On other OSes, the user session id is not necessarily recorded at all kernel-side.
# Using regular users in combination with /bin/su or /usr/bin/sudo ensure a clear audit track.
PermitRootLogin No

您可能需要像这样生成主机密钥/usr/bin/ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N ''

答案2

根据 @dave_thompson_085 的评论,问题出在客户端配置错误:

PubkeyAcceptedKeyTypes ssh-rsa阻止它使用 ed25519

相关内容