How to Secure a Game Server on Linux: 9-Step Checklist

Short answer: To secure a game server, log in with SSH keys instead of passwords, don't run the game server as root, and open only the game ports. Never expose admin interfaces like RCON or a REST API to the internet. Add a whitelist or password, keep everything updated, and keep backups on a second machine.

This checklist is for your own Linux server or VPS running Debian 13. On Ubuntu the commands are almost identical. It fits Minecraft, Valheim, Rust and most other games. You need root or sudo and some command-line experience. If you manage your server with a panel, watch for the "With ServerSheriff" boxes: a panel takes over some tasks but needs access to the server itself.

Before you start: Keep a second SSH session open while you change SSH and firewall settings. If you lock yourself out, only your provider's rescue console can help.

1. Secure a game server with SSH keys instead of passwords

Password logins are brute-forced around the clock. An SSH key is practically impossible to guess.

On your PC (not the server):

ssh-keygen -t ed25519
ssh-copy-id yourname@server-ip

Test the key login. Only when it works, disable passwords on the server. Create a file:

sudo nano /etc/ssh/sshd_config.d/99-hardening.conf

Contents:

PasswordAuthentication no
PermitRootLogin no

Then validate and reload:

sudo sshd -t && sudo systemctl reload ssh

PermitRootLogin no requires a normal user with sudo rights. Check what actually applies: sudo sshd -T | grep -E 'passwordauthentication|permitrootlogin'. Some provider images ship their own file in sshd_config.d/ that overrides your setting.

With ServerSheriff: When you connect your server ("Create node"), the panel logs in once via SSH as root with a password and installs everything. Keep password login on until the node shows as ready in the panel. After that, ServerSheriff only uses its own SSH key for the user control-panel. From then on you can:

  • change the root password,
  • set PasswordAuthentication no and PermitRootLogin no.

Don't touch: the user control-panel and its file /home/control-panel/.ssh/authorized_keys. If you use AllowUsers, include control-panel. If you change the SSH port, enter the new port in the panel under "Edit node". Otherwise "Update daemon" and "Delete node" stop working.

2. Firewall: open only what you need

ufw isn't preinstalled on Debian: sudo apt install ufw. Allow SSH first, then the game ports, and enable it last:

sudo ufw default deny incoming
sudo ufw allow OpenSSH
sudo ufw allow 25565/tcp     # Minecraft Java
sudo ufw enable
sudo ufw status verbose

Typical ports:

GamePort for playingNever expose publicly
Minecraft Java25565/TCPRCON 25575/TCP
Valheim2456–2457/UDPSupervisor 9001/TCP (Docker image only)
Palworld8211/UDP (community list: + 27015/UDP)RCON 25575/TCP, REST API 8212/TCP

If your provider has a cloud firewall, use it as well. It filters traffic before it reaches your server.

With ServerSheriff: The panel needs two ports on your server: SSH (22 or your custom port) and the daemon on 3000/TCP. If you use ufw, allow both before running ufw enable:

sudo ufw allow OpenSSH
sudo ufw allow 3000/tcp

Otherwise the panel loses its connection to the node. The panel sets up game ports and SFTP (default 2222/TCP) through Docker. ufw doesn't filter them (see step 3). If you use your provider's firewall, open each new game server's ports there yourself. The panel doesn't control provider firewalls.

3. Warning: Docker bypasses ufw

This is the most common mistake with game servers in Docker. According to Docker's docs, published ports are routed around ufw. If your compose.yaml contains

ports:
  - "25575:25575"

then RCON is reachable from the internet, even though ufw doesn't allow it.

Do this instead:

  • Don't publish admin ports if you only need them inside the container, e.g. via docker exec.
  • Or bind them to localhost, so only the server itself can reach them:
ports:
  - "8211:8211/udp"             # game: public
  - "127.0.0.1:8212:8212/tcp"   # REST API: local only

Reach a localhost-bound port from your PC through an SSH tunnel: ssh -L 8212:127.0.0.1:8212 yourname@server-ip.

Check what is actually listening:

sudo ss -tulpn

If an admin port shows 0.0.0.0 or [::], it's open to everyone.

4. Protect RCON and admin APIs

RCON is remote control for the server console. Minecraft's RCON is not encrypted: password and commands travel in plain text. The Minecraft Wiki recommends using RCON only from localhost.

  • Minecraft: keep enable-rcon=false unless you need it. If you do, use a long random rcon.password and don't expose port 25575.
  • Palworld: Pocketpair states that the REST API is not designed to be exposed directly to the internet. Keep 8212 local. Always set AdminPassword.
  • Valheim (Docker image): the Supervisor web UI on 9001 is off by default. Keep it off, or bind it to localhost with a password.

Generate a random password with openssl rand -base64 24.

5. Players: whitelist, password, online mode

Game server security: protect RCON and admin APIs
  • Minecraft: for private servers use the whitelist: /whitelist on, then /whitelist add PlayerName. With enforce-whitelist=true, players removed from the list get kicked. Keep online-mode=true; without it, anyone can join under any name, including yours.
  • Valheim: choose a long server password (5 characters is the minimum, more is better). For friends, hide the server from the public list and use Join IP.

Give admin rights (OP, adminlist.txt, AdminPassword) only to people you really trust.

6. Never run the game server as root

If the game server runs as root and has a vulnerability, the attacker owns the whole machine.

  • Without Docker: create a system user, e.g. sudo adduser --system --group --home /opt/minecraft minecraft, and start the service with User=minecraft.
  • With Docker: many images run as root inside the container by default. Use PUID/PGID or user: in compose.yaml where supported. Read the image notes; for the Valheim image, older versions break the 1.0 world conversion when run as non-root.

7. Keep things updated

  • System: unattended-upgrades installs Debian security updates automatically: sudo apt install unattended-upgrades and sudo dpkg-reconfigure -plow unattended-upgrades. Bigger updates: sudo apt update && sudo apt upgrade.
  • Game server: new server builds often fix vulnerabilities. Keep plugins and mods current and download them only from known sources.
  • Docker images: docker compose pull && docker compose up -d.

With ServerSheriff: unattended-upgrades is fine on a node. Turn it on only after the node is ready, and keep the default (security updates only). The panel action "Update packages" installs all updates and reboots the server afterwards, so your game servers go offline briefly. Plan it for a quiet time. If the action fails, an automatic update is probably running. Just try again later. For game updates, use "Update on start" on the game server.

8. Backups on a second machine

A backup on the same server won't help against disk failure, a deleted server or an attacker. Keep at least one copy on another device.

  • Back up the world with the server stopped, or use the game's or image's backup feature.
  • Copy backups off the server automatically, e.g. with rsync.
  • Test a restore. A backup you've never restored is just a hope.

With ServerSheriff: Create and restore backups with one click in the panel, or on a schedule. They're stored on your node under /opt/control-panel/backup/ (one folder each for game servers, databases and web servers). The off-site copy is up to you, e.g.:

rsync -a /opt/control-panel/backup/ backup-target:/path/to/folder/

Run the copy when no backup schedule is active. The backups are not encrypted, so copy them only to a place you trust or to an encrypted target.

9. Watch the logs

Secure a game server: watch the logs
  • SSH logins: sudo journalctl -u ssh --since today
  • Game server: docker compose logs --since 1h or the server's log file.
  • Optional: fail2ban bans IPs after many failed attempts. With key-only SSH it matters less, but keeps logs clean.

What about DDoS?

No setting on your server stops a large flood attack. Your provider has to filter it upstream. Ask whether your plan includes DDoS protection. For home servers, don't share your home IP publicly, only with the people you play with.

Common mistakes

  • Publishing RCON or API ports in Docker and relying on ufw.
  • Running ufw enable before allowing SSH: locked out.
  • Disabling password login before testing the key.
  • online-mode=false on a public Minecraft server.
  • Backups only on the same server.

Less manual work with ServerSheriff

Half of this list is maintenance: backups, schedules, ports, access. That's exactly what a panel takes off your plate. With ServerSheriff you manage your game servers in the browser instead of over SSH:

  • Every game server in its own Docker container, isolated from each other and not running as root (step 6 done).
  • CPU and RAM limits per game server, so one server can't slow down the others.
  • Backups by click or schedule, restore by click.
  • Game updates on start or by button.
  • SFTP access per game server folder, instead of giving all your friends SSH.
  • Two-factor login for your panel account.
  • Console and logs live in the browser.

You bring your own Debian server, the panel sets it up. Securing server access (steps 1 and 2) stays with you, using the notes above. The Free plan costs nothing, needs no credit card and covers one server with up to 5 applications.

→ Try ServerSheriff for free

FAQ

Is a long password good enough instead of an SSH key? A very long, unique password beats a short one. A key is still safer and more convenient, because it can't be guessed.

Should I change the SSH port? Not required. A different port reduces log noise but isn't real protection. Key-only login is.

Is Docker more secure than a normal service? Docker isolates the game server from the system, but it doesn't replace a firewall or updates. And it opens published ports around ufw.

How do I check which ports are open from outside? On the server: sudo ss -tulpn. From another machine: nmap against your own server IP. Only scan servers you own.

With ServerSheriff

ServerSheriff is a web panel for your own server. Connect it once, then manage game servers, databases and Docker in your browser. The Free plan costs nothing, needs no credit card and includes 1 node and up to 5 applications.

→ Try for free · Manage game servers and databases with ServerSheriff