Secure SSH access
Use this guide to secure root SSH for administration. On Enhance, normal secondary-server communication uses TCP 9096 and browser access uses TCP 9095.
Make changes locally on each intended server with root or sudo access. You need a working authorized key and a provider console or another recovery route. Preserve the current SSH port and existing administrator configuration.
1. Choose your SSH policy
Section titled “1. Choose your SSH policy”Open an administrator-owned drop-in, for example:
sudo nano /etc/ssh/sshd_config.d/01-cpfence-hardening.confKeep a private copy if the file already exists. Choose one option below and preserve unrelated settings.
Option 1: Restrict root SSH to trusted IPs
Section titled “Option 1: Restrict root SSH to trusted IPs”PubkeyAuthentication yesPermitRootLogin no
Match User root Address 192.0.2.10,2001:db8::10 PermitRootLogin prohibit-passwordMatch allOption 2: Allow root key login without an IP restriction
Section titled “Option 2: Allow root key login without an IP restriction”PermitRootLogin prohibit-passwordPubkeyAuthentication yesThis permits root key login from any address allowed by the firewall and other SSH rules. Root password and keyboard-interactive authentication are disabled by prohibit-password. Other SSH authentication requirements still apply. Ubuntu SSH configuration reference
2. Validate before reloading
Section titled “2. Validate before reloading”sudo sshd -tContinue only if it exits successfully without errors. Check the effective settings for an allowed source:
sudo sshd -T -C user=root,addr=192.0.2.10 | grep -E 'permitrootlogin|pubkeyauthentication'Expect pubkeyauthentication yes and permitrootlogin prohibit-password or without-password. For Option 1, repeat with a source outside your trusted list:
sudo sshd -T -C user=root,addr=192.0.2.30 | grep -i permitrootloginExpect permitrootlogin no. Repeat the allowed check with your IPv6 source when used. If your existing rules match a hostname, local address, or local port, supply the corresponding host, laddr, or lport connection fields too. OpenSSH test options
3. Reload and test a new connection
Section titled “3. Reload and test a new connection”After the syntax and effective-rule checks pass:
sudo systemctl reload sshOpen a second SSH connection using your existing port and key. Confirm the intended trusted source works before closing the original session. With Option 1, sources outside the list must remain denied root login.
Repeated root-login alerts
Section titled “Repeated root-login alerts”Several SSH connections can produce several successful root-session records. On the server named in the alert:
-
Check the source IP’s current policy. For verified administrator or cluster addresses, use the IPDB whitelist controls. A whitelist bypasses IPDB blocking and suppresses newly detected root-login alerts from that address; approve only trusted sources.
-
Review SSH clients and administration tools that open parallel connections.
-
Inspect recent SSH logins with this read-only check:
Terminal window sudo journalctl --unit=ssh --since='15 minutes ago' --lines=100 --no-pager -
Compare the dates, PIDs, usernames, and IPs with the notification. cPFence can group several logins in one notification. If the same record continues to arrive, share the relevant details privately with support.
Rollback and troubleshooting
Section titled “Rollback and troubleshooting”- Unexpected effective rule: review
/etc/ssh/sshd_configand its included files before reloading. - Key login fails: check authorized keys, their permissions, other authentication requirements, and provider/local firewall rules.
- Undo this change: restore your saved drop-in. If you created a new file, remove only that file. Run
sudo sshd -t, then reload SSH after it succeeds. Use the provider console if remote access is lost. - Browser or secondary-server access fails: follow browser access or secondary-server connection; changing SSH rules does not repair those listeners.
