Your first 30 minutes on a new Linux VPS: create it, SSH in with a key, lock it down
Most VPS tutorials start after the server exists, and most lockouts happen in the first half hour. This is the order I follow on every new Ubuntu 24.04 server, from creating it to a hardened, snapshotted base you can bui
Most VPS tutorials start after the server exists, and most lockouts happen in the first half hour. This is the order I follow on every new Ubuntu 24.04 server, from creating it to a hardened, snapshotted base you can build on. Each step ends with a check, so you never change two things at once.
Assumed: Ubuntu 24.04 LTS, a provider that lets you paste an SSH public key when you create the server, and a laptop with OpenSSH (Linux, macOS, or Windows 10/11 PowerShell). 203.0.113.10 stands in for your server's IP; deploy is the user we create.
Minutes 0β5: make a key, then create the server
Create the key before you create the server, so the server never has a password login to attack.
ssh-keygen -t ed25519 -C "laptop-2026"
cat ~/.ssh/id_ed25519.pub
Accept the default path (but answer n if it asks to overwrite an existing key), and set a passphrase. The .pub file is the one you share; the other never leaves your machine. On Windows, the same command works in PowerShell, and Get-Content $env:USERPROFILE\.ssh\id_ed25519.pub prints the public key. More detail, including ssh-agent on each OS, is in this SSH key guide.
Now create the server. On almost any provider it is the same four choices:
- Region. Pick the data centre closest to your users. Round-trip time adds up on every request.
- Image. Ubuntu 24.04 LTS, unless your software needs something else.
- Size. RAM is what runs out first. Roughly: 2 GB for a static site or small API, 4 GB for one to three cached WordPress sites, 8 GB for production WordPress with MySQL. Leave 25β30% headroom. The reasoning is in how much RAM a VPS needs.
-
SSH key. Paste the contents of
id_ed25519.pub.
Note the public IPv4 address when it comes up.
Minutes 5β8: first login and updates
The first connection asks you to confirm the host key fingerprint. Compare it with the one your provider's console shows if it offers one, then type yes.
apt update
apt upgrade -y
If a new kernel arrived, /var/run/reboot-required will exist. Reboot at the end, not halfway through.
Minutes 8β12: a sudo user with your key
Working as root makes every typo system-wide. Create a normal user and give it your key:
adduser deploy
usermod -aG sudo deploy
mkdir -p /home/deploy/.ssh
cp /root/.ssh/authorized_keys /home/deploy/.ssh/
chown -R deploy:deploy /home/deploy/.ssh
chmod 700 /home/deploy/.ssh
chmod 600 /home/deploy/.ssh/authorized_keys
Set a strong password at the adduser prompt. You will not log in with it, but sudo asks for it.
Check, from a second terminal on your laptop (keep the root session open):
ssh [email protected]
sudo whoami # prints: root
Do not go on until both work. Then save typing with an entry in ~/.ssh/config on your laptop:
Host web1
HostName 203.0.113.10
User deploy
IdentityFile ~/.ssh/id_ed25519
From now on, ssh web1.
Minutes 12β17: key-only SSH, no root login
On Ubuntu, /etc/ssh/sshd_config begins with Include /etc/ssh/sshd_config.d/*.conf, and for most settings sshd keeps the first value it reads. So a drop-in whose name sorts first beats both the main file and anything a cloud image added (some ship a 50-cloud-init.conf with PasswordAuthentication yes).
sudo tee /etc/ssh/sshd_config.d/00-hardening.conf >/dev/null <<'EOF'
PermitRootLogin no
PasswordAuthentication no
KbdInteractiveAuthentication no
EOF
sudo sshd -t
sudo systemctl restart ssh
sudo sshd -T | grep -Ei '^(permitrootlogin|passwordauthentication|kbdinteractiveauthentication)'
All three lines should end in no. Restarting does not drop your current session.
A 24.04-specific note: SSH is socket-activated (systemctl is-active ssh.socket says active). Restarting ssh is enough for the settings above. If you ever change Port or ListenAddress, you also need sudo systemctl daemon-reload and sudo systemctl restart ssh.socket, after opening the new port in every firewall.
Check, from a second terminal: ssh web1 works, and ssh [email protected] fails with Permission denied (publickey).
Minutes 17β20: firewall
Ubuntu ships ufw disabled. Its default policy denies incoming traffic, so allow SSH first:
sudo ufw allow OpenSSH
sudo ufw enable
sudo ufw status verbose
Only add web ports when a web server is actually running: sudo ufw allow 80,443/tcp. If your provider also has a network firewall in front of the VM, open the same ports there.
Check: a fresh ssh web1 from a second terminal still connects.
Minutes 20β25: updates, time, swap
Security updates are on by default on Ubuntu Server. Confirm rather than assume:
cat /etc/apt/apt.conf.d/20auto-upgrades # both lines should be "1"
systemctl status unattended-upgrades --no-pager
Set a timezone you can read in logs and cron, and a hostname you will recognise:
sudo timedatectl set-timezone Asia/Kolkata
sudo hostnamectl set-hostname web1
Add web1 to the 127.0.1.1 line in /etc/hosts so sudo stops warning about it.
On a 1β2 GB plan, a small swap file makes out-of-memory kills during upgrades or builds less likely. Check swapon --show first and skip this if swap exists:
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
sudo findmnt --verify
free -h
Run the tee -a line once only. Swap is a safety margin, not extra RAM; if the server swaps constantly, it needs a bigger plan.
Minutes 25β28: see what is listening
sudo ss -tlnp
On a fresh 24.04 server you should see port 22 (held by systemd and sshd because of socket activation) and the local resolver on 127.0.0.53 and 127.0.0.54. Anything on 0.0.0.0 or [::] is reachable from outside unless a firewall stops it. Repeat this after every service you install.
Optional: sudo apt install fail2ban. With passwords off, brute force cannot succeed, but fail2ban keeps the log noise down. Ubuntu's package enables the sshd jail by default; put your changes in /etc/fail2ban/jail.local.
Minutes 28β30: reboot, then snapshot
[ -f /var/run/reboot-required ] && sudo reboot
Log back in with ssh web1, then take a snapshot from your provider's panel. If a later change goes wrong you roll back to a clean, hardened, updated server. A snapshot lives on the same platform as the server, so keep an off-server backup of your data too.
What comes next
- Point your domain at it: an A record for
@andwwwwith the server's IPv4, AAAA only if IPv6 actually works, then Certbot. Step by step in point a domain to a VPS. - The longer version of this checklist, with the reasoning behind each step, is the Ubuntu VPS initial setup guide.
- If you would rather script it, vps-first-boot does the user, ufw, fail2ban, unattended-upgrades and key-only SSH steps, and refuses to disable passwords until the new user has logged in. Read it before you run it.
If you lock yourself out: use the provider's web or out-of-band console, which does not depend on SSH, and fix authorized_keys, the drop-in or the ufw rule from there.
How Bigdomainhost fits
For transparency: Bigdomainhost is an Indian hosting company that started trading in September 2026. Its Linux KVM VPS runs in Mumbai (BOM-1) or Delhi NCR (DEL-1) and offers Ubuntu 20.04, 22.04 and 24.04 images with full root access. If you paste a public key at order time, password login is disabled from the first boot, and a Linux VPS is usually ready in under 60 seconds. The panel firewall denies inbound traffic except SSH on port 22, so open 80 and 443 there as well as in ufw. The out-of-band console in the control panel still gets you in after a firewall mistake, and snapshots are taken from the instance view. Phone support runs in IST hours and WhatsApp is answered at any time. A walk-through of what a VPS is, and how to create one, is in what is a VPS.
Written by the Bigdomainhost team with AI assistance; facts checked against the linked sources.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.