Security
Nefo has root access to your server, so it protects its own sign-in first. It also gives you tools to protect the server and your websites. This page covers:
- the panel's own protection: the hidden address, HTTPS, sign-in limits, two-factor authentication, sessions and the activity log;
- the server's firewall (ufw), fail2ban and SSH settings, on the Firewall & SSH page;
- website security: the web application firewall, rate limits, blocked addresses and the malware scanner.
The panel's own protection
Hidden entrance path
The installer picks a random port between 20000 and 49999 and a secret path of 12 lowercase letters and digits. The panel only answers under that path, for example https://203.0.113.10:28443/k3x9p2qa7m1z/. Every other URL on that port returns 404, so a scanner can't tell that a panel runs there.
If you lose the address, run this on the server:
nefo infoIt prints the URL with the server's first IP address, and also with the panel's domain once it has one (see below). If the server sits behind a separate public address, run nefo info --host 203.0.113.10 to print the URL with it.
The port and the path are stored as listen and entrance in /etc/nefo/config.json. The panel has no setting to change them. To change the path by hand, set entrance to 8 to 32 lowercase letters and digits, then run systemctl restart nefo.
HTTPS from the first start
The panel serves HTTPS from its first start, with TLS 1.2 or newer. It creates a self-signed certificate in /var/lib/nefo/tls/, so your browser warns you the first time. To get rid of the warning, get a free Let's Encrypt certificate for a domain that points to this server:
- Install the web server from Websites if you haven't yet. Let's Encrypt checks the domain on port 80, and the web server answers it.
- Point the domain's A record to the server, without a proxy or CDN.
- Go to Settings → Certificate.
- Enter the Domain of the panel, for example
panel.example.com, and select Get certificate. - Open the panel at
https://panel.example.com:28443/k3x9p2qa7m1z/, with your own port and path.
The certificate renews on its own, like the websites' certificates; a failed renewal is retried every 12 hours. To remove it, select Delete: the panel goes back to its self-signed certificate. See SSL certificates for certificates in general.
Sign-in limits
- 5 failed attempts within 15 minutes lock the address out for 15 minutes. The sign-in page then says "Too many failed attempts. Try again in … seconds."
- A wrong password and a wrong two-factor code both count. So does a wrong current password in the password and 2FA forms of the Account page.
- IPv6 addresses are counted per /64 network, because one user usually controls a whole /64.
- A successful sign-in clears the count.
- A wrong username and a wrong password give the same message and take the same time, so the sign-in page doesn't reveal which usernames exist.
- The panel counts the address that connects to it and ignores
X-Forwarded-For. If you put a proxy in front of the panel, all visitors share one count.
Passwords are stored as bcrypt hashes, never in plain text.
TIP
If you lock yourself out, wait 15 minutes. The count is kept in memory, so restarting the panel on the server (systemctl restart nefo) also clears it.
Sessions and signing out
- A sign-in lasts 12 hours. After that you sign in again, even if you were active.
- To sign out, open the account menu at the top right and select Sign out.
- Changing your password signs you out on every device. So does
nefo reset-passwordon the server. - The session cookie can't be read by scripts, is only sent over HTTPS and only to the panel's own path.
Security headers
Every page is sent with a strict Content Security Policy that allows scripts only from the panel itself. The panel also sends X-Frame-Options: DENY, X-Content-Type-Options: nosniff, Referrer-Policy: no-referrer (which keeps the secret path out of other websites' logs) and a Permissions-Policy that turns off the camera, microphone and location. Every change needs a request header that other websites can't send, which blocks cross-site request forgery.
Two-factor authentication
Two-factor authentication (2FA) asks for a 6-digit code from an authenticator app at every sign-in, so a stolen password isn't enough. Any app that supports standard time-based codes works, such as Google Authenticator, Authy or 2FAS. While 2FA is off, the panel lists "Two-factor sign-in is off" as a serious problem.
Turn on 2FA
- Go to Account in the left menu. You can also open the account menu and select Password and 2FA.
- Under Two-factor authentication, select Set up.
- Scan the QR code with your app, or type the Setup key into it. The app lists the account as Nefo.
- Enter the 6-digit code that the app shows and select Turn on.
From now on, the sign-in page asks for a Two-factor code after your password.
Codes change every 30 seconds. The panel also accepts the previous and the next code, in case the clocks differ a little. Each code works only once: if a code is refused, wait for the next one.
Turn off 2FA
On Account, under Two-factor authentication, enter your Password and a current Code, then select Turn off.
If you lose your phone
Nefo has no backup codes. You recover through the server: sign in over SSH as root and run:
nefo reset-password --disable-2faThis sets a new random password for the admin account, turns off 2FA, signs out all sessions and prints the new password. Sign in with it, change the password and set up 2FA again. For another account, add --user and its name. See Command line.
WARNING
Without your phone, root access to the server is the only way back into the panel. Keep your SSH key or root password, or your provider's web console, safe.
Change the panel password
- Go to Account → Change password.
- Enter your Current password, then the New password twice (Repeat new password). It must be 12 to 72 characters long.
- Select Change password.
You are signed out on every device. Sign in again with the new password.
Activity log
Account → Recent activity shows the 100 newest entries, with the time, action, user, IP address and detail. Show All entries or only Failures, and type in the filter box to search. The top of the page shows your last sign-in and how many failed sign-ins the log holds.
The log records:
- sign-ins, sign-outs and failed sign-ins, with the reason (wrong username or password, or wrong 2FA code);
- password changes, password resets from the command line, and 2FA turned on or off;
- changes made in the panel: websites, certificates, databases, files, backups, cron jobs, services, firewall rules, SSH settings, software and Docker;
- opening and closing the terminal, with how long it was open;
- panel restarts and server reboots.
Automatic certificate renewals are recorded with the user system. Entries are kept for 90 days. Each entry is also written to the panel's service log, which you can read with journalctl -u nefo. fail2ban reads failed sign-ins from there.
Firewall (ufw)
Nefo manages the server's firewall with ufw. Go to Firewall & SSH → Firewall (ufw).
If the page says ufw is not installed, install it on the server. The panel doesn't install it:
apt install ufwTurn on the firewall
- Select Turn on the firewall and confirm.
- The panel first allows the SSH port (comment
SSH) and the panel's port (commentNefo). When a web server is installed, it also allows ports 80 and 443 for websites (commentWebsites), and 443/UDP when OpenLiteSpeed answers HTTP/3. Then it turns ufw on. It adds these rules even if you added a rule for one of these ports while the firewall was off, for example one limited to your address, so turning the firewall on never locks you out. To keep only your rule, delete the one for everyone afterwards (see the end of What the firewall refuses).
You can add rules before you turn the firewall on, for example for a port that another program on the server needs. While the firewall is off, the page shows them below Turn on the firewall as ufw commands, such as ufw allow 8080/tcp, in the Rule (ufw command) column, with each IPv4 and IPv6 pair shown once. They take effect when you turn the firewall on. ufw numbers its rules only while it is on, so to delete one of them, turn the firewall on first.
All other incoming ports are closed unless a rule allows them. When you install the web server later, with the firewall on, Nefo opens ports 80 and 443 at that time.
If your provider has a cloud firewall (security group), open the same ports there too. Nefo can't change it.
Add a rule
- Select Add rule.
- Choose Allow or Deny.
- In Port, e.g. 8080, enter one port, or a range such as
6000:6010. - Choose the Protocol: TCP, UDP, or TCP + UDP. A range needs one protocol: with TCP + UDP it becomes TCP.
- In From, enter an IP address or a network such as
198.51.100.0/24. Leave it empty to allow or deny everyone. - Optionally, add a Comment of up to 60 characters, without quotes.
- Select Add.
The page shows your own IP address above the list, which helps when you allow a port only for yourself.
ufw checks the rules from top to bottom and uses the first one that matches. A Deny rule with an address in From is put at the top of the list, so it takes effect even on a port that a later rule allows for everyone. Other rules are added at the end.
TIP
To keep an address away from one website only, use the website's Block access settings instead (see below).
The list also shows rules you added with ufw on the command line. Limit allows a port but refuses, for a while, an address that opens 6 connections within 30 seconds (ufw limit). Reject refuses like Deny, but tells the other side at once.
Delete a rule
Select the bin icon at the end of the rule's row and confirm. If the rules changed since you opened the page, the panel refuses and asks you to reload, so it never deletes the wrong rule.
What the firewall refuses
These guards stop you from locking yourself out:
- A rule that allows the SSH port or the panel's port shows protected when it is your last way in from the address you use now (shown above the list). It can't be deleted here. When another rule also lets your address in, the rule can be deleted.
- A Deny rule for the SSH port or the panel's port with an empty From is refused. A Deny rule for one address or network is allowed.
To let only your own address reach the panel: add an Allow rule for the panel's port with your address in From, then delete the rule that allows the port from anywhere (and its IPv6 copy). If your address changes later, use your provider's web console to run ufw allow <port>/tcp.
Rules for remote database access (port 3306) are added and removed from the Databases page. Change them there. See Databases.
Brute-force protection (fail2ban)
fail2ban blocks addresses that keep failing to sign in, to SSH and to the panel.
Install fail2ban
- Go to Firewall & SSH → Brute-force protection (fail2ban).
- Select Install fail2ban. The install runs in the background with a live log.
Nefo sets up two jails in /etc/fail2ban/jail.d/panel.conf:
| Jail | Watches | Blocks after | Block time |
|---|---|---|---|
sshd | SSH sign-ins, SFTP included | 5 failures within 10 minutes | 1 hour |
panel | sign-ins to the panel that fail, or are refused while the address is locked out | 10 within 10 minutes | 1 hour |
A blocked address can't reach the port that the jail protects. The panel's own sign-in limit (5 failures in 15 minutes) acts first. An address that keeps trying while it is locked out is then blocked by the panel jail in the firewall.
The panel rewrites this file, and its filter in /etc/fail2ban/filter.d/panel.conf, so don't edit them by hand. When you change the SSH port, the sshd jail follows it.
See and unblock addresses
The table lists each Protected service, its Recent failures and the addresses Blocked now, with the number of blocks in total. To unblock an address, select Unblock next to it.
If fail2ban is installed but stopped, start it on the Services page.
TIP
If you blocked yourself from SSH, sign in to the panel from your current network and select Unblock. You can also run fail2ban-client set sshd unbanip 203.0.113.10 from the panel's Terminal.
SSH settings
Go to Firewall & SSH → SSH.
| Setting | Choices |
|---|---|
| Port | 1 to 65535 |
| root sign-in | With an SSH key only (recommended), With a key or a password, Not allowed |
| Allow sign-in with a password | On or off, for every account |
Select Save. The panel writes its settings to /etc/ssh/sshd_config.d/00-panel.conf, which takes precedence over the other SSH settings files. It also turns off keyboard-interactive sign-in. Before it restarts SSH, it tests the new settings with sshd -t. If the test fails, the old file comes back and nothing changes.
WARNING
Keep your current SSH session open after you save. Open a new connection and check that you can sign in before you close the old one.
What the SSH settings refuse
- Settings with which nobody could sign in over SSH any more. For example: turning off password sign-in while no account has an SSH key; root sign-in With an SSH key only while root has no key; or root Not allowed while no other account can sign in.
- A port that is already taken: the panel's own port, 80, 443, or any port another program listens on.
To decide, the panel looks at root and at the people's accounts (UID 1000 and up) with a login shell: their keys in ~/.ssh/authorized_keys (or the files set by AuthorizedKeysFile), their passwords, and AllowUsers, DenyUsers, AllowGroups and DenyGroups. It doesn't read Match blocks. The page lists who can sign in now, and how (key or password). When root has no key, it also shows a warning.
- A new port when SSH is started by systemd socket activation. The page then shows socket activated and the port field is locked. Change the port on the command line.
SSH can't be stopped from the Services page, only restarted or reloaded.
WARNING
With root sign-in Not allowed, you need another account that can use sudo, or you can sign in but not manage the server over SSH. Nefo doesn't create that account, and doesn't check that it can use sudo.
Change the SSH port
- Enter the new Port, select Save and confirm.
- If the firewall is on, the panel opens the new port (comment
SSH) before SSH moves to it. If fail2ban is installed, itssshdjail moves to the new port too. - If your provider has a cloud firewall, open the new port there too.
- Test a new connection, for example
ssh -p 2222 [email protected]. - The firewall rule for the old port stays, and is no longer protected. Delete it under Firewall (ufw) once the new port works.
The SFTP accounts of your websites connect on the same port.
Turn off password sign-in
- Add your public key to
/root/.ssh/authorized_keysand check that you can sign in with it. - Turn off Allow sign-in with a password and select Save.
The SFTP accounts of your websites keep their own sign-in method, password or key, even with password sign-in off for SSH.
While root can sign in with a password, the panel lists "Root can sign in over SSH with a password" as a serious problem.
Website security
Each website has its own security settings. Go to Websites, open the website by selecting its name or Settings, and use the tabs under Security.
Web application firewall
The web application firewall (WAF) is ModSecurity with the OWASP Core Rule Set, both free and open source. It checks every request and stops SQL injection, cross-site scripting (XSS), file inclusion, known scanners and other common attacks. It works with Nginx, Apache and OpenLiteSpeed.
- Install it once: Software → Web firewall (ModSecurity) → Install. Websites keep the firewall off until you turn it on.
- Go to Websites → (site) → Web firewall (WAF).
- Choose a mode:
- Off
- Detect only: log attacks, block nothing
- Block attacks: the visitor gets HTTP 403.
- Select Save.
Start with detect only for a few days, and check the events for false alarms before you block. Websites that run WordPress or use the WordPress or Drupal rewrite preset get the rule set's exceptions for those applications automatically.
Recent firewall events lists the 50 newest requests that the rules flagged on this website: the time, the IP address, the request, the rules that matched, and whether it was blocked or only logged. The events come from /var/log/panel-waf/audit.log, which is rotated daily and kept for 7 days.
Only the first 13 MB of a request are inspected, so large uploads still work. If you remove the WAF on the Software page, each website keeps its mode, which applies again when you reinstall.
Rate limit and blocked addresses
Go to Websites → (site) → Block access.
- Rate limit (requests per second per visitor, 0 = off): counts PHP and app requests only, not images, CSS or scripts. Bursts of up to five times the limit are allowed; above that, visitors get HTTP 429. 10 suits most websites, and the highest value is 1000. Only Nginx has this setting: on Apache and OpenLiteSpeed it isn't shown.
- Blocked IP addresses: one IPv4 or IPv6 address or range per line, such as
203.0.113.7or198.51.100.0/24, up to 200 per website. Blocked visitors get HTTP 403.
Select Save. Both work on their own, without the web application firewall. The same tab has Password protection, described in Websites.
Malware scan
The scanner looks for web shells, backdoors, hidden code and injected scripts in a website's files. It changes nothing until you quarantine a file.
- Go to Websites → (site) → Malware scan.
- Select Scan now. The scan runs in the background with a live log.
The scanner reads the website's folder, such as /var/www/example.com. It skips .git folders and files over 5 MB, and doesn't follow symbolic links. It checks PHP files (also PHP code in files with other names), JavaScript and HTML files, and images.
| Finding | Severity |
|---|---|
| Known web shell | critical |
| Runs code sent by the visitor | critical |
| Calls a function named by the visitor | critical |
| Runs shell commands sent by the visitor | critical |
| Runs hidden (encoded) code | high |
| Decodes hidden data sent by the visitor | high |
| Builds a function from the visitor's input | high |
| Uploader that lets the visitor choose where files go | high |
| Obfuscated script injection | high |
| PHP code hidden in an image | high |
| Code execution through preg_replace /e | check |
| Long encoded data next to code that decodes it | check |
| Heavily obfuscated text next to code that runs it | check |
| PHP file in an uploads folder | check |
Each finding shows the file, the line and a short excerpt. A PHP file in an uploads folder that holds only a comment, like WordPress's "Silence is golden" index.php, is not reported.
The panel keeps the latest scan of each website. It doesn't scan on a schedule: start a scan when you want one.
Quarantine and restore
Select Quarantine next to a finding to move the file out of the website, into /var/lib/panel-quarantine, which only root can read. The panel records the file's owner and permissions.
Under Quarantined files:
- Restore puts the file back where it was, with its owner and permissions. It is refused if a file now exists at that path, or if the folder no longer exists.
- Delete removes the file for good, after you confirm.
When you delete a website, its quarantined files are deleted too.
WARNING
Quarantining a file that the website needs, such as a plugin file, can break the website. Check the excerpt first, and restore the file if it was a false alarm.
Scan with ClamAV
ClamAV is an optional, extra scan engine.
- Install ClamAV antivirus on the Software page. Its virus databases download in the background for a few minutes after the install.
- On Malware scan, tick Also scan with ClamAV (slower, needs about 1.4 GB of free memory) and select Scan now.
ClamAV needs about 1.4 GB of free memory while it scans, so it suits servers with 2 GB or more. If less memory is free, the panel skips ClamAV and says so in the report. ClamAV runs at the lowest CPU priority and skips files over 25 MB. Its findings are marked high.
SSH sign-in history
The list of SSH sign-ins and failed attempts is on the Processes page. See SSH sign-ins.