
The private key is placed on your local machine and the public key is uploaded to the server. Basically, you generate a key pair (private key and public key). SSH Key authentication only allows connections from clients whose key matches the one on the server. However, if your password gets leaked, it is a major risk as anyone who knows your password will be able to get into the server. With password authentication, you can connect to your server from any location, you only need to fill in your password.

Therefore, it is highly recommended to use SSH Key authentication method for connections to your servers. It is definitely more secure than the usual SSH password authentication.

SSH keys are one of the most secure SSH authentication options.
