How to Set Up a Ubuntu VPS from Scratch
Just got a fresh Ubuntu VPS? These five steps get you from first login to a secure, updated server ready to host your apps. Copy-paste the commands as you go.
1. Log in over SSH
Use the IP address and root password from your welcome email. On macOS/Linux open a terminal; on Windows use PowerShell or a client like PuTTY.
ssh root@YOUR_SERVER_IP
Accept the fingerprint prompt the first time and enter your password.
2. Update the system
Always patch a new server before anything else:
apt update && apt upgrade -y
3. Create a sudo user
Working as root all the time is risky. Create a regular user with sudo rights:
adduser deploy
usermod -aG sudo deploy
Replace deploy with any username you like, and set a strong password when prompted.
4. Set up SSH keys
SSH keys are more secure than passwords. From your own computer, generate a key (if you don't have one) and copy it to the server:
# On your local machine
ssh-keygen -t ed25519
ssh-copy-id deploy@YOUR_SERVER_IP
Now you can log in as ssh deploy@YOUR_SERVER_IP without a password. For hardening (disabling root login and password auth), see our Linux VPS security checklist.
5. Enable a basic firewall
Ubuntu ships with UFW. Allow SSH and your web ports, then turn it on:
sudo ufw allow OpenSSH
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
That's it — your Ubuntu VPS is updated, has a secure user and a firewall. From here you can install a web server, Docker, or a control panel.
Need a Ubuntu VPS to follow along?
Deploy a full-root Linux VPS in India from Rs. 400/mo, NVMe + KVM.
Get a Linux VPS