VPS Security
This guide will help you secure your VPS server against unauthorized access and attacks.
Overview
| Feature | Details |
|---|---|
| SSH Keys | RSA 4096-bit, Ed25519 |
| Firewall | UFW (Uncomplicated Firewall) |
| Protection | Fail2ban |
| Availability | 24/7 |
System Updates
First, update your system:
apt update
apt upgrade -yAutomatic Updates
apt install unattended-upgrades
dpkg-reconfigure unattended-upgradesCreating a Non-Root User
Create a new user for daily work:
adduser newuser
usermod -aG sudo newuserNow log in as the new user and use sudo for administrative tasks.
SSH Key Setup
Generate a Key
On your local machine:
ssh-keygen -t ed25519 -C "[email protected]"Copy Key to Server
ssh-copy-id -i ~/.ssh/id_ed25519.pub [email protected]Verify Connection
SSH Configuration
Edit the SSH configuration file:
sudo nano /etc/ssh/sshd_configRecommended Settings
| Parameter | Value | Description |
|---|---|---|
Port | 2222 | Non-standard port |
PermitRootLogin | no | Disable root login |
PasswordAuthentication | no | Disable password auth |
PubkeyAuthentication | yes | Enable key auth |
MaxAuthTries | 3 | Max attempts |
After changes, restart SSH:
sudo systemctl restart sshdWarning: Before disconnecting, verify you can log in with the new method!
Firewall Setup (UFW)
# Installation
sudo apt install ufw
# Allow SSH (YOUR port!)
sudo ufw allow 2222/tcp
# Allow HTTP/HTTPS
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
# Allow from specific IP
sudo ufw allow from 192.168.1.100 to any port 2222
# Enable firewall
sudo ufw enable
# Show status
sudo ufw status verboseFail2ban Installation and Configuration
Fail2ban protects against brute-force attacks:
sudo apt install fail2ban
sudo systemctl enable fail2ban
sudo systemctl start fail2banCustom Configuration
sudo nano /etc/fail2ban/jail.local[sshd]
enabled = true
port = 2222
maxretry = 3
bantime = 3600
findtime = 600sudo systemctl restart fail2banSecurity Checklist
| Task | Status |
|---|---|
| System updated | [ ] |
| Non-root user created | [ ] |
| SSH keys configured | [ ] |
| SSH port changed | [ ] |
| Root login disabled | [ ] |
| Password auth disabled | [ ] |
| Firewall active | [ ] |
| Fail2ban installed | [ ] |
| Strong password set | [ ] |
Emergency Recovery
Locked Out of Server
If you cannot log in:
- Open VNC Console in the CoreSynth dashboard
- Log in as root
- Check and fix SSH settings
- Restart SSH:
systemctl restart sshd
Disable Firewall via VNC
ufw disableNext Steps
- Linux Basics — Get familiar with the terminal
- Firewall — Advanced firewall configuration
- Backups — Back up your data
Need help? Open a support ticket or ask Alex.
Last updated on