A virtual server (VPS) is a server created by splitting a physical server through virtualization, with its own operating system, root access and dedicated resources. The provider delivers the server in a few minutes, but making it secure and ready to use is your job. In this guide we walk through what to do on a new virtual server, from the first connection to the security settings, using Ubuntu; we also cover the differences for Windows servers.
Before Setup: Choosing Resources and an Operating System
The right starting plan depends on what you will run on the server. The table below is a general starting point; real needs vary with traffic and the application:
| Use case | Recommended operating system | What to watch at the start |
|---|---|---|
| WordPress or a PHP site | Ubuntu LTS, Debian, AlmaLinux | Enough RAM for the database, SSD/NVMe disk |
| Node.js, Python, Docker applications | Ubuntu LTS, Debian | RAM based on the number of apps and containers |
| Remote desktop, Windows software, .NET/IIS | Windows Server | At least 2 GB RAM for Windows Server; more for desktop use |
| Game server, bot, VPN | Ubuntu LTS or Debian | CPU speed, network latency and traffic limit |
On Linux, choosing a long-term support (LTS) release means you get security updates for years. You can find the differences between a virtual and a physical server in our VPS vs dedicated server comparison.
1. Connect to the Server over SSH
When the server is delivered you receive an IP address and a root password (or an SSH key). On Windows 10/11, macOS and Linux you can connect directly from a terminal:
ssh root@SERVER_IPOn the first connection you are asked to confirm the server’s fingerprint. If you can’t connect over SSH, use the VNC/console screen in your provider’s panel.
2. Update the System
apt update && apt upgrade -yThis installs the security updates released after the installation image was built. If the kernel was updated, restart the server with reboot.
3. Create a User with sudo Rights
Doing daily work as a sudo user instead of root limits the impact of a wrong command and lets you disable root login:
adduser admin
usermod -aG sudo adminOn Debian and Ubuntu the privileged group is sudo; on AlmaLinux and Rocky Linux it is wheel.
4. Switch to SSH Key Login
Using an SSH key instead of a password makes brute-force password attempts useless. Create the key on your own computer and copy it to the server:
# On your own computer
ssh-keygen -t ed25519
ssh-copy-id admin@SERVER_IPOn systems without ssh-copy-id, add the contents of ~/.ssh/id_ed25519.pub to /home/admin/.ssh/authorized_keys on the server. Then confirm that ssh admin@SERVER_IP logs you in without a password.
5. Disable Root and Password Login
Once key login works, set these lines in /etc/ssh/sshd_config:
PermitRootLogin no
PasswordAuthentication noOn some images, files in the /etc/ssh/sshd_config.d/ folder (for example the cloud-init file on cloud images) can override these settings, so check that folder too. Then test the configuration and restart the service:
sudo sshd -t
sudo systemctl restart sshImportant: Try logging in from a second terminal before closing your current session. If something goes wrong, you can fix it from the open session. The service is called ssh on Ubuntu and Debian and sshd on RHEL-based distributions.
6. Enable the Firewall
On Ubuntu, use UFW to open only the ports you need. Add the SSH rule before enabling the firewall, or your connection will drop:
sudo ufw allow OpenSSH
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
sudo ufw statusOn AlmaLinux and Rocky Linux, firewalld (firewall-cmd) does the same job.
7. Automatic Security Updates, Time Zone and Hostname
sudo apt install unattended-upgrades
sudo dpkg-reconfigure --priority=low unattended-upgrades
sudo timedatectl set-timezone Europe/Istanbul
sudo hostnamectl set-hostname server1Automatic updates make sure security patches are installed even if you forget. The correct time zone makes logs and scheduled tasks easier to read.
8. Install Your Applications and Set Up Backups
After the basic settings you can install the software you need: Nginx or Apache, PHP and MySQL/MariaDB for a website; Node.js, Python or Docker for applications. If you want easier management, you can also install a control panel.
The last and most often skipped step is backup. The provider’s snapshot feature is useful for a quick rollback, but it isn’t enough on its own; keep a regular, tested backup of your database and files outside the server.
Differences on a Windows Virtual Server
- You connect with Remote Desktop (RDP) instead of SSH: on Windows, open Remote Desktop Connection with the
mstsccommand and connect with the IP address and Administrator credentials. - The first tasks are installing updates through Windows Update and changing the Administrator password to a strong one.
- Allowing access to the RDP port (3389) only from your own IP addresses in the firewall greatly reduces password attempts.
Management After Setup: A Short Checklist
- Monitor disk, RAM and CPU usage regularly (
df -h,free -m,htop). - Check weekly that updates and backups are actually happening.
- Turn off services and ports you don’t use.
- Take a snapshot before important changes.
For more management tips, see our article on best practices for managing virtual servers, and if you want to build a virtualization platform, our guide to virtual server setup on VMware ESXi.
Conclusion
Setting up a virtual server doesn’t end when the provider hands it over. Installing updates, switching to a sudo user and SSH keys, disabling root and password login, enabling the firewall and setting up backups can all be done in the first half hour and make your server much more secure. If you want to start with a server with root access, take a look at our VPS server and VDS server plans.
Categories
-
CentOS 7 guides
-
cPanel 20 guides
-
CyberPanel 18 guides
-
Operating Systems 81 guides
-
Juniper Networks 18 guides
-
Control Panels 50 guides
-
Linux 17 guides
-
MySQL 29 guides
-
Network 95 guides
-
Plesk Panel 12 guides
-
Virtual Servers 273 guides
-
SEO 3 guides
-
Cyber Security 8 guides
-
Technology 162 guides
-
VMware 36 guides
-
WordPress 20 guides
-
Artificial Intelligence 22 guides