Initial VPS Server Setup Guide
The first things to do on a new VPS are: install all updates, create a non-root user with sudo, turn on a firewall that allows only SSH, switch off root and password logins over SSH, and enable automatic security updates.
Step 1: Update Your System
After connecting via SSH, immediately update all packages:
apt update && apt upgrade -y
Step 2: Create a Non-Root User
Running everything as root is a security risk. Create a regular user with sudo access:
adduser yourusername
usermod -aG sudo yourusername
Step 3: Set Up a Firewall
Enable UFW (Uncomplicated Firewall) and allow only necessary ports:
ufw allow OpenSSH
ufw enable
Add more ports as needed for your applications (e.g., ufw allow 80,443/tcp for web traffic).
Step 4: Configure SSH Security
Edit /etc/ssh/sshd_config to improve security:
- Set
PermitRootLogin no(after setting up your non-root user) - Set
PasswordAuthentication no(after setting up SSH keys)
Restart SSH: systemctl restart sshd
Step 5: Enable Automatic Updates
Install unattended-upgrades to automatically apply security patches:
apt install unattended-upgrades -y
dpkg-reconfigure -plow unattended-upgrades
Next Steps
Your VPS is now secured and ready. Install your application stack - whether that's a web server, game server, or development environment.