Question: how ssh key authentication works?
Answer: SSH keys are a matching set of cryptographic keys which can be used for authentication. ... The server then check its authorized_keys file for the public key, generate a random string and encrypts it using the public key. This encrypted message can only be decrypted with the associated private key.