Secure your server · 10 min
Secure your server in the first 10 minutes
Update the system, create a normal user and turn off password logins for root.
A new server is reachable from the whole internet, and automated bots start trying to log in within minutes. These steps close the most common doors. They're written for Ubuntu and Debian.
1. Update everything
apt update && apt upgrade -y2. Turn on automatic security updates
apt install -y unattended-upgrades
dpkg-reconfigure --priority=low unattended-upgrades3. Create a normal user
Working as root all the time is risky. Create your own user and give it admin rights (replace deploy with any name):
adduser deploy
usermod -aG sudo deployCopy your SSH key to the new user so you can sign in as them:
rsync --archive --chown=deploy:deploy ~/.ssh /home/deploy4. Turn off password logins
Once key login works, stop SSH from accepting passwords and root logins:
sed -i 's/^#\?PasswordAuthentication .*/PasswordAuthentication no/' /etc/ssh/sshd_config
sed -i 's/^#\?PermitRootLogin .*/PermitRootLogin no/' /etc/ssh/sshd_config
systemctl restart sshFrom now on, sign in as your user and use sudo for admin commands.
5. Allow only what you need
Turn on the Rack'Em firewall and allow just SSH and the ports your apps use. See Set up the firewall.
Locked yourself out?
The web console works without SSH, so you can always get back in and undo a change.
Stuck? Contact us or open a support ticket from your panel.