How to Set Up a VPS for the First Time
You just got your first VPS. Now what? This guide walks you through the initial setup — from connecting via SSH to securing your server, configuring a firewall, and installing your first application. No prior Linux experience required.
What You'll Need
- A VPS with a Linux operating system (Ubuntu 22.04 or 24.04 recommended for beginners)
- Your server's IP address (provided by your hosting provider)
- Your root password or SSH key (also provided by your host)
- An SSH client: Terminal (Mac/Linux) or PuTTY / Windows Terminal (Windows)
Step 1: Connect to Your VPS via SSH
SSH (Secure Shell) is how you remotely control your VPS through a command-line interface. Open your terminal and type:
ssh root@your-server-ip
Replace your-server-ip with the IP address from your hosting provider (e.g., ssh [email protected]).
The first time you connect, you'll see a message about the host's authenticity. Type yes to continue. Enter your password when prompted.
On Windows, you can also use PuTTY — enter your IP address in the "Host Name" field, keep port 22, and click Open.
Step 2: Update Your System
The first thing to do on any new VPS is update all installed packages to their latest versions. This patches security vulnerabilities and ensures you have the newest software:
apt update && apt upgrade -y
This command does two things: apt update refreshes the package list, and apt upgrade -y installs all available updates. The -y flag automatically confirms the installation.
This may take a few minutes. If prompted about configuration files, press Enter to keep the existing configuration.
Step 3: Create a Non-Root User
Running everything as root is a security risk. Create a regular user with sudo privileges:
# Create a new user (replace 'myuser' with your preferred username)
adduser myuser
# Add the user to the sudo group
usermod -aG sudo myuser
# Test the new user
su - myuser
sudo whoami # Should output: root
exit # Return to root
From now on, you can log in as this user and use sudo before commands that need admin privileges.
Step 4: Set Up SSH Key Authentication (Recommended)
SSH keys are more secure than passwords. They use cryptographic key pairs — a private key on your computer and a public key on the server.
Generate a Key Pair (on your local computer)
# Run this on YOUR computer, not the VPS
ssh-keygen -t ed25519 -C "[email protected]"
Press Enter to accept the default file location. Optionally set a passphrase for extra security.
Copy the Key to Your VPS
# From your local computer
ssh-copy-id myuser@your-server-ip
Now you can log in without a password: ssh myuser@your-server-ip
Disable Password Authentication
Once SSH keys work, disable password logins to prevent brute-force attacks:
sudo nano /etc/ssh/sshd_config
Find and change these lines:
PasswordAuthentication no
PubkeyAuthentication yes
Save with Ctrl+O, exit with Ctrl+X, then restart SSH:
sudo systemctl restart sshd
Step 5: Configure the Firewall
UFW (Uncomplicated Firewall) is the easiest way to manage firewall rules on Ubuntu:
# Allow SSH connections (IMPORTANT: do this BEFORE enabling the firewall!)
sudo ufw allow ssh
# Enable the firewall
sudo ufw enable
# Check status
sudo ufw status
Add rules for services you'll run:
# Web server (HTTP + HTTPS)
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
# Minecraft server
sudo ufw allow 25565/tcp
# Custom port
sudo ufw allow 8080/tcp
Warning: Always allow SSH (port 22) before enabling the firewall. If you enable UFW without allowing SSH, you'll lock yourself out of your VPS.
Step 6: Install Common Software
Depending on what you want to run, install the appropriate software:
For Web Applications
# Install Nginx web server
sudo apt install nginx -y
sudo systemctl enable nginx
sudo systemctl start nginx
# Your server now shows a welcome page at http://your-server-ip
For Node.js Applications / Discord Bots
# Install Node.js 20 LTS
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
# Install PM2 for process management
sudo npm install -g pm2
For Python Applications
sudo apt install python3 python3-pip python3-venv -y
For Java Applications (Minecraft servers, JDA bots)
sudo apt install openjdk-21-jre-headless -y
java -version
For Docker
curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker myuser
# Log out and back in for group changes to take effect
Step 7: Set Up Automatic Security Updates
Keep your server patched automatically:
sudo apt install unattended-upgrades -y
sudo dpkg-reconfigure -plow unattended-upgrades
Select "Yes" to enable automatic updates. This installs security patches automatically without requiring manual intervention.
Essential Linux Commands Reference
| Command | What It Does |
|---|---|
ls | List files in current directory |
cd /path | Change directory |
pwd | Show current directory path |
mkdir name | Create a new directory |
cp file1 file2 | Copy a file |
mv file1 file2 | Move or rename a file |
rm file | Delete a file |
nano file | Edit a file in the terminal |
cat file | Display file contents |
htop | Monitor CPU, RAM, and processes |
df -h | Check disk space usage |
free -h | Check RAM usage |
sudo reboot | Restart the VPS |
What's Next?
Your VPS is now secured and ready to use. Here are some next steps depending on your project:
- Host a Minecraft server — Follow our modded server setup guide
- Deploy a Discord bot — See our 24/7 bot hosting guide
- Host a website — Set up Nginx with a domain name and SSL certificate
- Learn more about VPS — Read our What is a VPS? guide
Need a VPS? Azion Cloud offers Linux VPS plans with NVMe SSDs, DDoS protection, and a Mumbai data center. View our VPS plans and deploy your first server in minutes.