Secure a new VPS: users, keys and firewall
Create a normal user, switch to key login and allow only the ports you need.
Create an admin user
adduser deploy
usermod -aG sudo deployUse an SSH key
- On your computer run
ssh-keygen -t ed25519. - Copy the key with
ssh-copy-id deploy@YOUR.SERVER.IP. - Test the login in a new window before the next step.
Close the door
Set PasswordAuthentication no and PermitRootLogin no in /etc/ssh/sshd_config, then restart SSH. Next enable the firewall:
ufw allow OpenSSH
ufw allow 80,443/tcp
ufw enableImportant: Keep one SSH session open while you test, so a typo does not lock you out.
