Skip to content

ecdsa-sha2-nistp521 Signature verification failed #1472

@fyac

Description

@fyac

I tried to connect to the switch, but encountered a signature verification error. By adjusting the DEFAULT_SERVER_HOST_KEY constant and moving the ecdsa-sha2-nistp521 algorithm to the end, I was able to pass the verification. It seems that there is an issue with the verification step for the ecdsa-sha2-nistp521 algorithm? Additionally, I also noticed two other issues where connection attempts to Huawei switches failed verification, and similarly, the failures occurred when the ecdsa-sha2-nistp521 algorithm was matched. I used Terminus to connect to this switch, and the verification passed, also using ecdsa-sha2-nistp521.

#925
#904

Custom crypto binding not available

Local ident: 'SSH-2.0-ssh2js1.16.0'
Client: Trying x.xx.xx.xxx on port xxx ...
Socket connected
Remote ident: 'SSH-2.0--'
Outbound: Sending KEXINIT
Inbound: Handshake in progress
Handshake: (local) KEX method: [email protected],curve25519-sha256,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group15-sha512,diffie-hellman-group16-sha512,diffie-hellman-group17-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,ext-info-c,[email protected]
Handshake: (remote) KEX method: diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1
Handshake: KEX algorithm: diffie-hellman-group-exchange-sha1
Handshake: (local) Host key format: ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-512,rsa-sha2-256,ssh-rsa
Handshake: (remote) Host key format: ecdsa-sha2-nistp521,ssh-dss,ssh-rsa
Handshake: Host key format: ecdsa-sha2-nistp521
Handshake: (local) C->S cipher: aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],[email protected]
Handshake: (remote) C->S cipher: aes256-ctr,aes128-ctr,aes256-cbc,aes128-cbc,3des-cbc
Handshake: C->S Cipher: aes128-ctr
Handshake: (local) S->C cipher: aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],[email protected]
Handshake: (remote) S->C cipher: aes256-ctr,aes128-ctr,aes256-cbc,aes128-cbc,3des-cbc
Handshake: S->C cipher: aes128-ctr
Handshake: (local) C->S MAC: [email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
Handshake: (remote) C->S MAC: hmac-sha2-256,hmac-sha2-256-96,hmac-sha1,hmac-sha1-96,hmac-md5,hmac-md5-96
Handshake: C->S MAC: hmac-sha2-256
Handshake: (local) S->C MAC: [email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
Handshake: (remote) S->C MAC: hmac-sha2-256,hmac-sha2-256-96,hmac-sha1,hmac-sha1-96,hmac-md5,hmac-md5-96
Handshake: S->C MAC: hmac-sha2-256
Handshake: (local) C->S compression: [email protected],zlib
Handshake: (remote) C->S compression: none,zlib
Handshake: C->S compression: zlib
Handshake: (local) S->C compression: [email protected],zlib
Handshake: (remote) S->C compression: none,zlib
Handshake: S->C compression: zlib
Outbound: Sending KEXDH_GEX_REQUEST
Received DH GEX Group
Outbound: Sending KEXDH_GEX_INIT
Received DH GEX Reply
Received DH Reply
Host accepted by default (no verification)
Host accepted (verified)
Outbound: Sending NEWKEYS
Inbound: NEWKEYS
Verifying signature ...
Signature verification failed
Outbound: Sending DISCONNECT (3)
Uncaught Error Error: Handshake failed: signature verification failed
    at makeError (/xx/ssh2/lib/protocol/utils.js:142:15)
    at doFatalError (/xx/ssh2/lib/protocol/utils.js:184:13)
    at finish (/xx/ssh2/lib/protocol/kex.js:709:18)
    at parse (/xx/ssh2/lib/protocol/kex.js:1267:23)
    at onKEXPayload (/xx/ssh2/lib/protocol/kex.js:1828:20)
    at decrypt (/xx/ssh2/lib/protocol/crypto.js:612:26)
    at parsePacket (/xx/ssh2/lib/protocol/Protocol.js:2028:25)
    at parse (/xx/ssh2/lib/protocol/Protocol.js:313:16)
. ..
Process exited with code 1

Terminus Logs:

👤 Starting a new connection to: "xxx" port "xxx"
⚙️ Address resolution finished
⚙️ Starting SSH session
⚙️ Remote server: SSH-2.0--
⚙️ Agreed KEX algorithm: diffie-hellman-group14-sha1
⚙️ Agreed Host Key algorithm: ecdsa-sha2-nistp521
⚙️ Agreed server-to-client cipher: aes256-ctr MAC: hmac-sha2-256
⚙️ Agreed client-to-server cipher: aes256-ctr MAC: hmac-sha2-256
⚙️ Agreed client-to-server compression: none
⚙️ Agreed server-to-client compression: none
⚙️ Handshake finished
👤 Checking host key: SHA256:c+YEbnDPsGL5tJBUQRn05uZBg2v4Q/Zj9UggaxvabBg
❗ Host xx is unknown
👤 Connection to "xx accepted
👤 Authenticating to xx as "xx"

In the other two cases, the issue could be circumvented by adjusting the algorithm, but my algorithm may need to connect to many devices. I'm not sure if this is a general problem. Are there any better solutions to address this?

node version: v24.12.0 ,I don't think Node is the culprit here. It's likely something else.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions