0

I'm logging into a Debian box and I get the security alert showing me the host public key. When I compare the full public key reported by PuTTY to the one in ~/.ssh/authorized_keys I find that they don't match.

Have I been MITM'd or am I misunderstanding something?

3
  • 1
    The key(s) in user-home-dir/.ssh/authorized_keys is(are) the keys if any FOR THE CLIENT AKA USER, and the key displayed by putty is the key FOR THE SERVER AKA HOST. They should ALWAYS be different. On Debian (and most Unix) the host keys are in /etc/ssh/ssh_host_${type}_key[.pub] Aug 1, 2021 at 2:33
  • to verify i'm understanding: the ideal way to verify i'm connecting to who i think i'm connected to is to physically go to my server, note the public key, then make sure it matches w/ what my ssh client says.
    – Rob
    Aug 1, 2021 at 2:58
  • it's not clear to me what role the private key /etc/ssh/ssh_host_${type}_key plays in the connection. it's not clear how having the server send me a public key helps when an attacker could just check what public key is being sent from the server being attacked, get in the middle and just spoof that exact same public key.
    – Rob
    Aug 1, 2021 at 3:02

1 Answer 1

2

it's not clear to me what role the private key /etc/ssh/ssh_host_${type}_key plays in the connection. it's not clear how having the server send me a public key helps when an attacker could just check what public key is being sent from the server being attacked, get in the middle and just spoof that exact same public key

To be clear, the server isn't actually re-sending your public key back to you. The server has its own completely separate key that it's sending to you – the "host key". Both the public and private parts of the host key are stored in /etc/ssh.

The server doesn't just send the public key; it also sends a signature made using the corresponding private key, which the client can use as proof. (The data being signed is unique for each connection.) An attacker could send the same public key but couldn't produce a signature.

This is also how certificates work in SSL/TLS (HTTPS and such).

Your own authentication key is also verified by the server in the same way – i.e. PuTTY doesn't only send your public key alone, but uses your private key to sign the message, so that someone else couldn't log in as you just by looking at your authorized_keys file.

1
  • ok this clears it all up. this and @dave_thompson_085 's contribution are my answer
    – Rob
    Aug 1, 2021 at 6:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .