So I started to use ssh on a server and I noticed that there are two ways of authenticating. I can either just type ssh@username and then provide password or I can use -i command and then select a key file that I have on my drive to give as an argument?

I though the key was necessary to encrypt the communication. If the key file is not provided what is the key used to encrypt the communication?


The users key is used for authentication of the user only, similar to the optional client certificate in TLS (which includes HTTPS). Encryption is done with a key created using a key exchange algorithm like Diffie-Hellman but only after authorizing the server to protect against man in the middle attacks. Insofar is SSH similar to TLS.
For more information have a look at Understanding the SSH Encryption and Connection Process.

| improve this answer | |
  • @SteffenUlrich Thanks, I will read the link to understand better – yoyo_fun Dec 22 '16 at 19:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.