Join our Telegram: @serverrental_wiki | BTC Analysis | Trading Signals | Telegraph
Setting Up Your First VPS: A Beginner's Tutorial
Setting up your first VPS can seem daunting, but with this step-by-step tutorial you will have a fully configured, secure server ready for hosting websites or applications within an hour.
Prerequisites
- A VPS from a provider like PowerVPS
- An SSH client (Terminal on Mac/Linux, PuTTY or Windows Terminal on Windows)
- Basic command line knowledge
Step 1: Log In to Your VPS
After purchasing a VPS, you will receive an IP address and root credentials. Connect:
ssh root@YOUR_VPS_IP
Accept the host key fingerprint when prompted.
Step 2: System Update
apt update && apt upgrade -y
If the kernel was updated, reboot:
reboot
Step 3: Create a Non-Root User
adduser deploy usermod -aG sudo deploy
Switch to the new user to verify:
su - deploy sudo apt install htop # test sudo access
Step 4: Set Up SSH Keys
On your local machine (not the VPS):
ssh-keygen -t ed25519 -f ~/.ssh/vps_key ssh-copy-id -i ~/.ssh/vps_key deploy@YOUR_VPS_IP
Now log in without a password:
ssh -i ~/.ssh/vps_key deploy@YOUR_VPS_IP
Step 5: Harden SSH
Edit /etc/ssh/sshd_config on the VPS:
Port 2222 PermitRootLogin no PasswordAuthentication no PubkeyAuthentication yes MaxAuthTries 3
Restart SSH:
sudo systemctl restart sshd
Important: Keep your current session open and test the new config in a second terminal before closing.
Step 6: Install a Firewall
sudo apt install ufw sudo ufw default deny incoming sudo ufw default allow outgoing sudo ufw allow 2222/tcp # new SSH port sudo ufw allow 80/tcp sudo ufw allow 443/tcp sudo ufw enable
Step 7: Install Fail2Ban
sudo apt install fail2ban sudo systemctl enable --now fail2ban
This automatically blocks IPs that repeatedly fail login attempts.
Step 8: Install a Web Server
Nginx
sudo apt install nginx sudo systemctl enable --now nginx
Visit http://YOUR_VPS_IP in a browser — you should see the Nginx welcome page.
Configure a Basic Site
Create /etc/nginx/sites-available/mysite:
server {
listen 80;
server_name example.com www.example.com;
root /var/www/mysite;
index index.html;
}
Enable it:
sudo ln -s /etc/nginx/sites-available/mysite /etc/nginx/sites-enabled/ sudo nginx -t sudo systemctl reload nginx
Step 9: Install SSL with Let's Encrypt
sudo apt install certbot python3-certbot-nginx sudo certbot --nginx -d example.com -d www.example.com
Certbot automatically configures HTTPS and sets up auto-renewal.
Step 10: Set Up Automatic Updates
sudo apt install unattended-upgrades sudo dpkg-reconfigure unattended-upgrades
Choose "Yes" to enable automatic security updates.
What's Next?
Your VPS is now secured and ready. Common next steps include:
- Installing a database (MySQL, PostgreSQL)
- Setting up Docker
- Deploying your application
- Configuring monitoring tools