1

When we ssh to a host, he is either known or not. In the latter case during our first try to connect we are prompted to

The authenticity of host '13x.8x.xx.1x1 (13x.8x.xx.1x1)' can't be established. RSA key fingerprint is xx:xx:xx:xx:xx:26:86:80:5f:17:xx:xx:xx:xx:6d:6c. Are you sure you want to continue connecting (yes/no)? yes

Then the server's RSA public Key is stored in the .ssh/know_hosts file. How is it encoded? And how can we ensure that this is not a man-in-the-middle? Finally, this so-called 'host key' is assymetric. What does this mean?

1 Answers1

3

How can we ensure this is not a man-in-the-middle?

The first time, you can check the RSA fingerprint. Someone needs to previously communicate it to you, or you need to somehow receive it securely (ie published via a https site, or received via a signed email). Many hosting providers, for example, send you your hosts SSH fingerprint.

On Ubuntu, you can find your own RSA fingerprint using:

ssh-keygen -lf /etc/ssh/ssh_host_rsa_key.pub

Note that there are other in-use fingerprint formats (dsa and ecdsa), depending on the server and client config. In your known_hosts file you can see the format in which each fingerprint has been stored.

How is it encoded?

The known_hosts file is a list of hostnames (or often, hashes of hostnames), the type of the fingerprint, and the fingerprint itself (cryptographic information) in base64 encoding. The format details can be found in the OpenSSH man page, under the SSH_KNOWN_HOSTS FILE FORMAT section.

This so-called 'host key' is asymmetric. What does this mean?

These asymmetric mechanisms mean that while the fingerprint allows you to verify the identity of the server, you cannot use it to generate a valid identification (to impersonate) that server.

It must be noted that the fingerprint (and the corresponding private key) are used as secret for cryptographic operations: a random challenge is sent from the client to the server. The server, which has the private key, can sign that challengue and send it back, then the client can verify the signature is valid because the fingerprint is appropriate.

In other words, the cryptographic secret is two-fold, the private key can cipher or sign, and the public key can be used to decipher or verify a signature. One of the keys can be made public at no risk, and used to verify signatures and to cipher text that only the owner of the private key will be able to decode. This is roughly what asymmetric means in cryptography.

jjmontes
  • 24,679
  • 4
  • 39
  • 51