How to Set Up a VPS from Scratch: No SSH Fear
The provider emailed an IP and a temporary root password. That is access, not a finished server.
Some links on this site are affiliate links. If you buy through them, we earn a commission at no extra cost to you. We only recommend tools we would deploy ourselves.
How to set up a VPS begins by replacing temporary root access with a named sudo account and an SSH key. Keep the provider console open until the new login works.
VPS setup commands
apt update && apt upgrade -y
adduser deploy
usermod -aG sudo deploy
ufw allow OpenSSH
ufw enable
apt install -y unattended-upgrades fail2ban
On your computer, create a key if needed:
ssh-keygen -t ed25519
ssh-copy-id deploy@YOUR_SERVER_IP
ssh deploy@YOUR_SERVER_IP
An SSH key proves identity with a private file on your computer instead of a reusable password. Confirm the deploy login and sudo -v before changing root SSH policy.
How to secure the VPS login
Edit /etc/ssh/sshd_config.d/99-hardening.conf:
PermitRootLogin no
PasswordAuthentication no
Run sshd -t before systemctl reload ssh. A syntax check is the difference between hardening and locking yourself out. DigitalOcean offers the easiest documentation path; Vultr is a strong region-flexible alternative. Compare them in the Vultr vs DigitalOcean breakdown.
VPS setup troubleshooting
If key login fails, check ownership of ~/.ssh and authorized_keys. If UFW blocks the session, use the provider console and restore the OpenSSH rule. If a service is unreachable, open only its required port and confirm it is listening with ss -ltnp.
Finish with sudo reboot, reconnect as the named user, and verify the firewall before deploying an application.
DigitalOcean
Developer-first cloud. The default Droplet in every GitHub tutorial.
Vultr
Fast, cheap, global cloud instances.
NordVPN
Consumer VPN with a huge server network.
Found the fix? The tool that ends the problem is one click away.
The Stack