Configure SSH on a VPS
Context
I am not a teacher, this is my own, an insignificant student, Aaron (Iso) Pescasio's notes.
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.
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"I press the "Enter" key 3 times, then copy the full content of the generated .pub file.
VPS
I connect to my server.
ssh username@Your_VPS_IPv4 -p PortNumberI create the ~/.ssh/authorized_keys file (if it doesn't already exist) and paste the content of the .pub file into it.
nano ~/.ssh/authorized_keysFinally, I disable password authentication and restart the SSH service using this bash script.
sudo sed -i "s/^#PasswordAuthentication yes/PasswordAuthentication no/" /etc/ssh/sshd_config
sudo systemctl restart sshdI reconnect to my server and normally no password will be asked.
ssh username@Your_VPS_IPv4 -p PortNumberLast updated on: