Independent hosting operator since 2014 · New York · Dallas · Amsterdam Status Looking Glass Contact
D4 NetworksD4 Networks
Client area Deploy a server
Home / Resources / The first ten minutes on a new VPS

Guides

The first ten minutes on a new VPS

May 5, 2026 · 11 min read

A fresh VPS comes with root access open to the internet. These six steps take about ten minutes and apply to both families we run: Ubuntu and Debian use apt and ufw; AlmaLinux, Rocky, and other RHEL-based distros use dnf and firewalld.

1. Log in and update all packages

Your OS image was built before today's security patches existed, so update first.

your machine
$ ssh [email protected]
Ubuntu and Debian
$ apt update && apt -y upgrade
RHEL-based
$ dnf -y upgrade

If the upgrade installed a new kernel, run reboot now and log in again.

2. Create a non-root user with sudo

When you work as root all the time, every mistake has full system access. A sudo user limits the damage and keeps a record of the commands you run.

Ubuntu and Debian
$ adduser deploy
$ usermod -aG sudo deploy
RHEL-based
$ useradd -m deploy
$ passwd deploy
$ usermod -aG wheel deploy

3. Add your SSH key and disable password and root login

Keys cannot be guessed the way passwords can, and root should never be a remote login target.

your machine
# skip ssh-keygen if you already have a key
$ ssh-keygen -t ed25519
$ ssh-copy-id [email protected]
$ ssh [email protected]

When key login works, edit the SSH config and set:

/etc/ssh/sshd_config
PermitRootLogin no
PasswordAuthentication no

Cloud images often override this file

Check /etc/ssh/sshd_config.d/ for extra config files (such as 50-cloud-init.conf) that set PasswordAuthentication. These files override the main file, so fix those lines too.

Do not lock yourself out before restarting SSH

Keep your current session open, restart SSH, then check that key-only login works from a second terminal. If it fails, you still have an open session to undo the change.

Ubuntu and Debian
$ sudo systemctl restart ssh
RHEL-based
$ sudo systemctl restart sshd

Work as your new user from here on.

4. Turn on the firewall

With default deny, a service you forgot about is not reachable from the internet.

Ubuntu and Debian
$ sudo apt install -y ufw
$ sudo ufw allow OpenSSH
$ sudo ufw enable
RHEL-based
$ sudo systemctl enable --now firewalld
$ sudo firewall-cmd --permanent --add-service=ssh
$ sudo firewall-cmd --reload

When you set up a web stack later, open ports 80 and 443 the same way. Our firewall guide covers the details.

5. Add fail2ban

fail2ban bans IPs that fail SSH logins again and again. This stops most brute force attempts and keeps your auth logs readable.

Ubuntu and Debian
$ sudo apt install -y fail2ban
RHEL-based
$ sudo dnf install -y epel-release
$ sudo dnf install -y fail2ban

Enable the SSH jail, then start the service:

/etc/fail2ban/jail.local
[sshd]
enabled = true
ssh session
$ sudo systemctl enable --now fail2ban
$ sudo fail2ban-client status sshd

6. Enable automatic security updates

Security patches should install even when you are not logging in to the server.

Ubuntu and Debian
$ sudo apt install -y unattended-upgrades
$ sudo dpkg-reconfigure -plow unattended-upgrades
RHEL-based
$ sudo dnf install -y dnf-automatic

On RHEL-based systems, set these two lines, then enable the timer:

/etc/dnf/automatic.conf
upgrade_type = security
apply_updates = yes
ssh session
$ sudo systemctl enable --now dnf-automatic.timer

Quick reference

StepUbuntu and DebianRHEL-based
Update packagesapt update && apt -y upgradednf -y upgrade
Sudo useradduser + usermod -aG sudouseradd + passwd + usermod -aG wheel
SSH service namesshsshd
Firewallufwfirewalld
fail2banapt install fail2banepel-release first, then dnf install fail2ban
Auto updatesunattended-upgradesdnf-automatic

Where to go next

With this base done, point your DNS at the server, install your stack, and set up off-site backups. Take a snapshot before any big change. You can find stack-specific guides in the rest of the Resources section, and if you get stuck, open a ticket.

security ssh firewall fail2ban updates ubuntu debian almalinux

Related articles