Skip to content

Commit

Permalink
Better debugging when keys are not matching
Browse files Browse the repository at this point in the history
  • Loading branch information
nviennot committed Apr 14, 2020
1 parent 339e6c4 commit cbec43f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tmate-ssh-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ static void on_ssh_client_event(struct tmate_ssh_client *client)

if (ssh_get_publickey_hash(pubkey, SSH_PUBLICKEY_HASH_SHA256,
&hash, &hash_len) < 0) {
kill_ssh_client(client, "Cannot authenticate server");
kill_ssh_client(client, "Failed to get server fingerprint");
return;
}

Expand Down Expand Up @@ -362,15 +362,17 @@ static void on_ssh_client_event(struct tmate_ssh_client *client)
}

match = !strcmp(hash_str, server_hash_str);
if (!match) {
kill_ssh_client(client, "Server fingerprint not recognized: "
"`%s', expected `%s'", server_hash_str, hash_str);
}

ssh_key_free(pubkey);
ssh_clean_pubkey_hash(&hash);
free(hash_str);

if (!match) {
kill_ssh_client(client, "Cannot authenticate server");
if (!match)
return;
}

/*
* At this point, we abort other connection attempts to the
Expand Down

0 comments on commit cbec43f

Please sign in to comment.