1

In sshd(8) man page:

The OpenSSH SSH daemon supports SSH protocol 2 only. Each host has a host-specific key, used to identify the host. Whenever a client connects, the daemon responds with its public host key. The client compares the host key against its own database to verify that it has not changed. Forward secrecy is provided through a Diffie-Hellman key agreement. This key agreement results in a shared session key. The rest of the session is encrypted using a symmetric cipher.

(Emphasized by me)
Can someone explain to me how does the authentication process work? As I understand:

  1. Each host will have a unique ssh key (public and private)
  2. When a client connects to a server, the sshd daemon provides the client with a public key
  3. The client then do something that I don't understand
  4. After that, the rest of that session is encrypted.

Am I correct? Can someone explain in detail what does The client compares the host key against its own database to verify that it has not changed means?

1
  • Read man ssh sshd ssh-keygen.
    – waltinator
    Commented Jan 15, 2022 at 5:19

1 Answer 1

1

Can someone explain in detail what does The client compares the host key against its own database to verify that it has not changed means?

When you ssh into a (previously unknown) machine, you will get this query (for e.g. ECDSA-type key):

ssh user@newhost:

The authenticity of host 'newhost (<IP-address>)' can't be established.
ECDSA key fingerprint is SHA256:<fingerprint>.
Are you sure you want to continue connecting (yes/no/[fingerprint])?

When answering with yes:

Warning: Permanently added 'newhost,<fingerpint>' (ECDSA) to the list of known hosts.

The host fingerprint is now added to the file ~/.ssh/known_hosts(default location).

For future connections, the host can be uniquely identified with this fingerprint and the dialogue thus does not appear. If, however, the host fails to do so, you will receive a warning about a change in the host. This is to ensure that no one may just capture the host, redirect the domain, etc, without you as ssh-client receiving a warning about this.

Compare it to a website certificate that you manually accept once and if it changes the website is marked insecure.

1
  • Thank you. It's clear to me now.
    – vcth4nh
    Commented Jan 15, 2022 at 13:03

You must log in to answer this question.

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