These are some steps that I follow when I provision a small VPS for myself.
I SSH into the VPS and add my user.
NEW_USER=midir99
# Add user
adduser $NEW_USER
# Add user to sudoers group
usermod -aG sudo $NEW_USER
# Enable user lingering
loginctl enable-linger $NEW_USERI set up an SSH key for more security.
On my local machine
# Create the key with a secure passphrase
ssh-keygen -t ed25519
# Print and copy the public key
cat id_ed25519.pubOn the VPS, paste your public key at ~/.ssh/authorized_keys
On my local machine, update ~/.ssh/config for faster log in
Host vps
HostName vps-ip.com
User midir99
Port 22
IdentityFile /home/midir99/.ssh/id_ed25519
Validate the key login is configured correctly by running on your local machine: ssh vps
I disable them for more security
On the VPS,
Edit the /etc/ssh/sshd_config
Set PasswordAuthentication no
Set PermitRootLogin no
On the VPS run
ufw allow 22/tcp
ufw enable
ufw status# Find your timezone using
timedatectl list-timezones
# Then set it
timedatectl set-timezone America/New_Yorkapt install -y fail2ban
systemctl enable fail2ban
systemctl start fail2banThat's it, feel free to add recommendations, complains, comments, questions, demands, etc.