OpenSSH Invalid Signature Issues

Viewed 43

I have a OpenSSH server running on Debian, OpenSSH_8.4p1 Debian-5+deb11u1, OpenSSL 1.1.1n

I also have a Windows 10 client.

On the Windows client I am able to connect to my SSH server using both Putty and the Windows command line.

However, if I try to connect using the following script, written in C which use the LibSSH library

int main()
{
    ssh_session my_ssh_session;
    int rc;
    int port = 22;
    const char* password;
    int verbosity = SSH_LOG_FUNCTIONS;

    // Open session and set options
    my_ssh_session = ssh_new();
    if (my_ssh_session == NULL)
        exit(-1);
    ssh_options_set(my_ssh_session, SSH_OPTIONS_HOST, "10.10.10.100");
    ssh_options_set(my_ssh_session, SSH_OPTIONS_PORT, &port);
    ssh_options_set(my_ssh_session, SSH_OPTIONS_USER, "user");
    ssh_options_set(my_ssh_session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);

    // Connect to server
    rc = ssh_connect(my_ssh_session);
    if (rc != SSH_OK)
    {
        fprintf(stderr, "Error: %s\n",
            ssh_get_error(my_ssh_session));
        ssh_free(my_ssh_session);
        exit(-99);
    }

    // Verify the server's identity
    if (verify_knownhost(my_ssh_session) < 0)
    {
        ssh_disconnect(my_ssh_session);
        ssh_free(my_ssh_session);
        exit(-1);
    }

    // Authenticate ourselves
    password = "Password";
    rc = ssh_userauth_password(my_ssh_session, NULL, password);
    if (rc != SSH_AUTH_SUCCESS)
    {
        fprintf(stderr, "Error authenticating with password: %s\n",
            ssh_get_error(my_ssh_session));
        ssh_disconnect(my_ssh_session);
        ssh_free(my_ssh_session);
        exit(-1);
    }

    ssh_disconnect(my_ssh_session);
    ssh_free(my_ssh_session);
}

...it fails with the following error.

[2022/09/23 17:38:33.820462, 4] pki_verify_data_signature: ED25519 error: Signature invalid

[2022/09/23 17:38:33.820462, 3] ssh_packet_socket_callback: Processing 276 bytes left in socket buffer

[2022/09/23 17:38:33.820462, 3] ssh_packet_socket_callback: Packet: processed 0 bytes

[2022/09/23 17:38:33.824469, 3] ssh_packet_socket_callback: Packet: processed 0 bytes

[2022/09/23 17:38:33.824469, 3] ssh_connect: current state : 9 Error:

Interestingly (or maybe not!) when I make a successful connection using the Windows command line an entry is added into my known-hosts file that looks like:

10.10.10.100 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBG6Eh2II4A5J4fO2kgWfkAyWkU39PjLxw+zaLHjZQpTiFCF+tBI3QysQnmJ0Offp9fFg2VtCP1smfbsl8+10h4w=

With that entry present, when I run my program I get a different error, this time

[2022/09/23 17:44:12.181095, 2] ssh_packet_newkeys: Received SSH_MSG_NEWKEYS

[2022/09/23 17:44:12.181095, 4] ssh_pki_signature_verify: Going to verify a ecdsa-sha2-nistp256 type signature

[2022/09/23 17:44:12.181095, 4] pki_verify_data_signature: Invalid ECDSA signature

Can anyone shed any light on why this might be happening?

0 Answers
Related