We earn commissions when you shop through the links below. Learn more
How to Set Up a VPS: A Beginner’s Guide
Go from zero to a secure, working Linux server in about 30 minutes. Pick a provider, create your server with an SSH key, log in, lock it down and install your first app, with copy-and-paste commands for every step.
Ubuntu LTSAbout 30 minutesNo experience neededCopy-and-paste commands
Step 1
Choose a VPS provider
For learning and small projects, any of these is a great start. All of them give you full root access, let you add an SSH key when you create the server, and run Ubuntu.
Best for beginners
DigitalOcean
The cleanest dashboard and the best tutorials. Pay by the second and delete the server any time.
From about $4/month
Most RAM for the money
Hostinger
4 GB of RAM on the entry plan and an easy control panel, plus an extra 20% off through our link.
About $5.19/month on a 24-month term
Cheapest to learn on
RackNerd
Yearly KVM deals for about the price of one month elsewhere. Perfect for a practice server.
From about $11/year on promo
Need a server in a specific country? Vultr has more than 30 locations worldwide. Want DDoS protection included? Look at ShockHosting. Compare all of them in our guide to the best VPS hosting.
Step 2
Pick your plan, location and operating system
Step 3
Add your SSH key before you create the server
On the create-server page, choose SSH key as the login method instead of a password and paste in your public key. Your server then trusts your key from the very first login, and no password ever exists for bots to guess.
Don’t have a key yet? Run ssh-keygen -t ed25519 on your computer, or create one in seconds with our SSH Key Generator.
Show your public key
# macOS and Linux
cat ~/.ssh/id_ed25519.pub
# Windows PowerShell
Get-Content $env:USERPROFILE\.ssh\id_ed25519.pub
Copy the whole line, starting with ssh-ed25519.
Steps 4 and 5
Log in and update everything
When the server is ready, copy its IP address from your dashboard and connect from a terminal (PowerShell on Windows). Type yes when asked to trust the server.
Connect as root
ssh root@203.0.113.10
Install all updates
apt update && apt upgrade -y
If an update asks about a modified configuration file, choosing the default (keep the local version) is usually safe. Reboot afterwards with reboot if the kernel was updated.
Step 6
Create your own user
Working as root all the time is risky: one typo can wipe the server. Create a normal user with admin rights, copy your SSH key to it, and use sudo when you need root.
Then log out and back in as your new user with ssh deploy@203.0.113.10. Adding a key from another computer later? Use ssh-copy-id.
Create the user and give it sudo
adduser deploy
usermod -aG sudo deploy
Copy root’s SSH key to the new user
rsync --archive --chown=deploy:deploy ~/.ssh /home/deploy
Step 7
Lock down SSH and turn on the firewall
Allow SSH, then enable the firewall
sudo ufw allow OpenSSH
sudo ufw enable
Turn off password and root logins
echo -e "PasswordAuthentication no\nPermitRootLogin no" | sudo tee /etc/ssh/sshd_config.d/00-hardening.conf
sudo sshd -t && sudo systemctl restart ssh
Keep your current session open and test logging in from a second terminal before closing it. For the full 10-step checklist, including Fail2ban and automatic updates, see how to secure SSH.
Step 8
Install your first app
Your server is ready for anything. Two popular first steps:
A web server (Nginx)
sudo apt install nginx -y
sudo ufw allow 'Nginx Full'
Docker, for running apps in containers
curl -fsSL https://get.docker.com | sudo sh
sudo usermod -aG docker $USER
After installing Nginx, open http://your-server-ip in a browser and you should see the “Welcome to nginx” page. Log out and back in after adding yourself to the docker group. For the full official install and an important firewall tip, see how to install Docker on Ubuntu.
Step 9
Turn on backups
Most providers offer automatic backups or snapshots for a small monthly fee. Turn them on now, before you put anything important on the server. A snapshot also lets you experiment fearlessly: if you break something, roll back in a few clicks.
Your VPS checklist
- Server created with an SSH key
- Updates installed
- Your own sudo user
- Password and root logins off
- Firewall on
- Backups enabled
Server ready? Put it to work with our guide on how to host a website on a VPS.
FAQ
VPS setup questions, answered
How long does it take to set up a VPS?
Creating the server takes about a minute. Following every step in this guide, including updates, a new user, a firewall and SSH hardening, takes most beginners about 30 minutes.
Which Linux distribution should I choose?
Ubuntu 24.04 LTS is the best choice for most people. It is supported for years, works with almost every app, and nearly all tutorials are written for it. Debian is a great, slightly more minimal alternative.
How much does a VPS cost?
Small VPS plans start at around $4 to $6 a month, and some yearly deals cost about $10 to $15 for the whole year. Backups and extra storage usually cost a little more.
Can I use a VPS to host a website?
Yes. Install a web server such as Nginx or Apache, or a control panel, point your domain at the server’s IP address, and add a free SSL certificate with Let’s Encrypt.
What if I break my server?
Restore a snapshot or backup if you made one. Otherwise, you can rebuild or reinstall the server from your provider’s dashboard and start fresh in a few minutes.
Do I need a Windows VPS to connect from Windows?
No. You can manage a Linux VPS from Windows using the built-in ssh command in PowerShell or Windows Terminal, or an app like PuTTY.
Ready to create your server?
DigitalOcean is the easiest place to start: clean dashboard, great docs, and you can delete the server any time.