# Server hardening

Source: https://openpanel.sh/docs/security/hardening

How the setup hardens every connected server, in short, with a link to every change in detail.

When you connect a server, the setup hardens it before anything else runs on it. In short:

| Area | What the setup does |
|---|---|
| **Access** | Creates the `openpanel` user, which signs in only with a key OpenPanel holds. |
| **SSH** | Moves SSH to a random port, turns password and root sign-in off, allows only `openpanel`, and limits sign-in attempts. |
| **Firewall** | Turns on ufw: every incoming connection is refused except SSH on its new port, HTTP and HTTPS, and ports Docker publishes stay closed too. See [Firewall](/docs/security/firewall). |
| **Brute force** | fail2ban bans an address for an hour after repeated failed SSH sign-ins. |
| **Updates** | Installs every pending update, and turns on automatic security updates. |
| **Passwords** | Replaces the passwords of root, `openpanel` and the user you connected with by one new random password, for your provider's web console only. SSH never accepts it. |
| **Logs** | Keeps the system log across restarts, and rotates container logs. |
| **The agent** | Installs the signed [OpenPanel agent](/docs/servers/agent), which only connects out, runs under a systemd unit that keeps the rest of the system read-only to it, and signs in with a key that never leaves the server. |

The setup keeps a way in open at every moment: each change is checked from a new connection before the old one closes, and the SSH and firewall changes are put back if the check fails.

[What OpenPanel changes on your server](/docs/servers/what-changes) lists every change in detail, and [The setup steps](/docs/servers/setup-steps) says what can fail at each step.

## After a disconnect [#after-a-disconnect]

A clean disconnect removes the agent, OpenPanel's containers, key and settings, and turns password sign-in back on. The firewall and automatic updates stay: they only protect the server. See [Disconnect and force disconnect](/docs/servers/disconnect).