Getting a Hetzner VPS
Getting the VPS
I selected a Hetzner “CAX11” instance (2 vCPUs, 4GB RAM, 40GB SSD, €3.95/mo) running CentOS Stream 10. I chose Nuremberg for the location as this was the closest to me and, all this being an experiment, I chose the cheapest instance type. I knew that CentOS had a reputation for being a boring and stable server OS and so, being relatively uninformed in such matters, it seemed like a reasonable choice. It was also a chance to try out an OS that I was unfamiliar with.
My first attempt to create the server seemed to hang on the creating server step. After waiting more than twenty minutes I decided to give up, delete the server and try again. The second time the server creation completed within two minutes and I was then able to SSH into the server as “root” using the SSH key that I had selected when configuring the instance.
Securing the VPS
- Disabled password authentication for SSH by editing
/etc/ssh/sshd_configand settingPasswordAuthentication no. - Created a new user
chrisand added it to thewheelgroupuseradd -m -G wheel chris - Created a password for the new user
passwd chris - Copied .ssh/authorized_keys from the root user to the new user
mkdir /home/chris/.ssh cp /root/.ssh/authorized_keys /home/chris/.ssh/ chown -R chris:chris /home/chris/.ssh chmod 700 /home/chris/.ssh chmod 600 /home/chris/.ssh/authorized_keys - Checked that I could ssh into the server as “chris”
- Checked that I could sudo as “chris”
- Only allow “chris” to SSH into the server by editing
/etc/ssh/sshd_configand settingAllowUsers chris. - Restarted the SSH service
service sshd restart - Check that I can still SSH into the server as “chris” and that I cannot SSH in as “root”.
- Install updates
sudo dnf update - Install
fail2bansudo yum install epel-release sudo yum install fail2ban sudo systemctl enable --now fail2ban - Install
ufwsudo dnf install ufw - Check the default policies and ensure SSH is allowed
sudo ufw status verbose sudo ufw default deny incoming sudo ufw allow ssh - Enable the firewall
sudo ufw enable - Check that I can still SSH into the server as “chris”