Configure SSH on a VPS
Context
Instead of allowing password authentication on my VPS, I wanted to remove it and enforce SSH key authentication.
Local PC
First, I generate an SSH key.
I press the "Enter" key 3 times, then copy the full content of the generated .pub
file.
VPS
I connect to my server.
I create the ~/.ssh/authorized_keys
file (if it doesn't already exist) and paste the content of the .pub
file into it.
Finally, I disable password authentication and restart the SSH service using this bash script.
I reconnect to my server and normally no password will be asked.