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

OpenSSH client keeps sending RSA key instead of ECDSA

· 52CE 我爱测

Client is Ubuntu 16.04 with keychain , server is FreeBSD 10.3. There is only one key in ~/.ssh/authorized_keys on the server (this key is ECDSA p521 and not RSA), and the client has both private and public key inside ~/.ssh . The…

问题原文

原帖链接 · Manuth Chek · CC BY-SA 3.0

Client is Ubuntu 16.04 with keychain, server is FreeBSD 10.3. There is only one key in ~/.ssh/authorized_keys on the server (this key is ECDSA p521 and not RSA), and the client has both private and public key inside ~/.ssh. The problem is the client keeps sending all RSA keys available in its ~/.ssh first - see this verbose output:

OpenSSH_7.2p2 Ubuntu-4, OpenSSL 1.0.2g-fips  1 Mar 2016
debug1: Reading configuration data /home/manuth/.ssh/config
debug1: /home/manuth/.ssh/config line 1: Applying options for r2d2.manuth.life
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to r2d2.manuth.life [103.12.163.90] port 900.
debug1: Connection established.
debug1: identity file /home/manuth/.ssh/dqar type 3
debug1: key_load_public: No such file or directory
debug1: identity file /home/manuth/.ssh/dqar-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2 FreeBSD-20160310
debug1: match: OpenSSH_7.2 FreeBSD-20160310 pat OpenSSH* compat 0x04000000
debug1: Authenticating to r2d2.manuth.life:900 as 'manuth'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: [email omitted]
debug1: kex: host key algorithm: ecdsa-sha2-nistp521
debug1: kex: server->client cipher: [email omitted] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email omitted] MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp521 SHA256:awtuO9udROeroYOv3GJ8Z6xcHt4IQhjNkcKQ6eavuik
debug1: Host '[r2d2.manuth.life]:900' is known and matches the ECDSA host key.
debug1: Found key in /home/manuth/.ssh/known_hosts:10
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: manuth@wackypc
debug1: Authentications that can continue: publickey
debug1: Offering RSA public key: manuth@wackypc
debug1: Authentications that can continue: publickey
debug1: Offering RSA public key: manuth@wackypc
debug1: Authentications that can continue: publickey
debug1: Offering ECDSA public key: /home/manuth/.ssh/dqar
debug1: Server accepts key: pkalg ecdsa-sha2-nistp521 blen 172
debug1: Authentication succeeded (publickey).
Authenticated to r2d2.manuth.life ([103.12.163.90]:900).

Still the same output even when I specify this in ~/.ssh/config on the client:

host r2d2.manuth.life
IdentityFile ~/.ssh/dqar
Port 900

Tried removing all keys from keychain but no help. If I add an RSA public key to the server then specify the RSA private key in ~/.ssh/config on the client, it does pick up the RSA key straight away.

已采纳解答

原帖链接 · Manuth Chek · CC BY-SA 3.0

Found the answer from here: https://linux-audit.com/using-ed25519-openssh-keys-instead-of-dsa-rsa-ecdsa/

Basically I have to add this to the client's ~/.ssh/config:

IdentitiesOnly yes

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

资料来源与适用范围

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

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

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