Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does SSH need certificates?

Tags:

ssh

I have heard that SSH does not need certificates.

But for RSA authentication of SSH , it should make sure that public key belong to the server and it can be done with certificates.

But it does not use certificates.

So how does it do?

like image 985
kst Avatar asked Dec 23 '22 20:12

kst


1 Answers

No. It does NOT NEED them, but it CAN use them (but they are different then the certificates used in SSL! for various reasons). Certificates help only to delegate the verification to some certificate authority. To verify the public key, you just need to get the public key using "secure" channel.

So how you can verify the public key of the server you are connecting to?

There are several possibilities. The server admin will send you using different secure channel the public key of fingerprint of the public key. They can look like this:

  • Public key: ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAubiN81eDcafrgMeLzaFPsw2kNvEcqTKl/VqLat/MaB33pZy0y3rJZtnqwR2qOOvbwKZYKiEO1O6VqNEBxKvJJelCq0dTXWT5pbO2gDXC6h6QDXCaHo6pOHGPUy+YBaGQRGuSusMEASYiWunYN0vCAI8QaXnWMXNMdFP3jHAJH0eDsoiGnLPBlBp4TNm6rYI74nMzgz3B9IikW4WVK+dc8KZJZWYjAuORU3jc1c/NPskD2ASinf8v3xnfXeukU0sJ5N6m5E8VLjObPEO+mN2t/FZTMZLiFqPWc/ALSqnMnnhwrNi2rbfg/rd/IpL8Le3pSBne8+seeFVBoGqzHM9yXw==

    • You can store this one directly in your ~/.ssh/known_hosts prefixed with the server name and space.
  • Fingerprint SHA256:zzXQOXSRBEiUtuE8AikJYKwbHaxvSc0ojez9YXaGp1A bitbucket.org (RSA)

    • When you connect to the server for the first time, you are asked similar question:

      The authenticity of host 'bitbucket.org (104.192.143.3)' can't be established.
      RSA key fingerprint is SHA256:zzXQOXSRBEiUtuE8AikJYKwbHaxvSc0ojez9YXaGp1A.
      Are you sure you want to continue connecting (yes/no)?
      
    • Then it is your responsibility to verify that the fingerprint is the same as the one you got from your admin.
    • If you don't do that, you are in danger that somebody redirected your connection to some malicious server and you are connecting somewhere completely else. The host keys are unique and this attacker would have different key (and therefore different fingerprint) unless he already compromised the original server (and then you are screwed already).

There is also possibility to add the host keys to the SSHFP DNS record, which will eliminate the burden above (you should have DNSSEC, otherwise the DNS records can be modified the same way as your direct connection). For this to work, you need to turn it on in your ssh_config using VerifyHostKeyDNS options.

And what about the certificates?

SSH can use certificates. This is common in company environment, where you are already given a known_hosts file configured with the certificate authority, which is used to sign all the host keys (and usually also the clients authentication keys). In that case, you don't need anything from above and connecting to local infrastructure "just works". Note, these certificates are not X509 as used in SSL/TLS PKI. For more info about these certificates, see manual page for ssh-keygen, which explains that in detail.

like image 147
Jakuje Avatar answered May 19 '23 12:05

Jakuje