![]() |
|
Guide CyberPanel SSH Key Login and Disabling Password Login (the Ubuntu cloud-init Trap) - Printable Version +- AdminsForum (https://adminsforum.com) +-- Forum: Free & open-source control panels (https://adminsforum.com/Forum-free-open-source-control-panels) +--- Forum: CyberPanel (https://adminsforum.com/Forum-cyberpanel) +---- Forum: CyberPanel Guides & Tutorials (https://adminsforum.com/Forum-cyberpanel-guides-tutorials) +----- Forum: CyberPanel Security Guides (https://adminsforum.com/Forum-cyberpanel-security-guides) +----- Thread: Guide CyberPanel SSH Key Login and Disabling Password Login (the Ubuntu cloud-init Trap) (/Thread-guide-cyberpanel-ssh-key-login-and-disabling-password-login-the-ubuntu-cloud-init-trap) |
CyberPanel SSH Key Login and Disabling Password Login (the Ubuntu cloud-init Trap) - JAY - 10-26-2026 CyberPanel SSH Key Login and Disabling Password Login (the Ubuntu cloud-init Trap) Every server on the internet gets password guesses on SSH within minutes. Logging in with an SSH key instead of a password and then switching passwords off stops all of that cold. CyberPanel has a page for SSH keys, but turning password login off is where most people go wrong on Ubuntu: we did it the "obvious" way and password login stayed on. Here's the full, tested way, and how to check that it really worked. Before you start
Step 1: What does your server allow right now? This is what our server had, checked with Code: sshd -TCode: sshd -T | grep -Ei '^(port|passwordauthentication|permitrootlogin|pubkeyauthentication) 'Code: /root/.ssh/authorized_keysCode: /etc/ssh/sshd_config.d/50-cloud-init.confStep 2: Create a key on your own computer On Linux, macOS and Windows 10/11 (PowerShell has OpenSSH built in) it's the same command: Code: ssh-keygen -t ed25519 -C "my-laptop"Code: id_ed25519Code: id_ed25519.pubCode: cat ~/.ssh/id_ed25519.pubCode: ssh-ed25519Step 3: Add the public key in CyberPanel Security > Secure SSH ( Code: https://YOUR-SERVER-IP:8090/firewall/secureSSHPaste it and click Save Key: Two things we noticed:
Code: ssh-copy-id -i ~/.ssh/id_ed25519.pub root@YOUR-SERVER-IPNow test it from a new terminal on your computer: Code: ssh -i ~/.ssh/id_ed25519 root@YOUR-SERVER-IPStep 4: Turn off password login (and the trap) The CyberPanel page only has SSH Port and Permit Root Login; there's no switch for passwords. So it's a config file. On Ubuntu the clean way is a small file in Code: /etc/ssh/sshd_config.d/We put Code: PasswordAuthentication noCode: /etc/ssh/sshd_config.d/99-hardening.confCode: passwordauthentication yesCode: (publickey,password)The reason: for each setting, sshd uses the first value it reads, and it reads the files in Code: sshd_config.dCode: 50-cloud-init.confCode: PasswordAuthentication yesCode: 99-...The fix is a name that sorts before 50: Code: echo 'PasswordAuthentication no' > /etc/ssh/sshd_config.d/00-hardening.conf
rm -f /etc/ssh/sshd_config.d/99-hardening.conf
sshd -t && systemctl reload ssh
sshd -T | grep -i '^passwordauthentication'Code: 50-cloud-init.confWe renamed our file so it's read first, and tested both ways of logging in:
Code: sshd -tStep 5 (optional): Root login and the port
If you lock yourself out Log in through your provider's VNC/console (it uses the local login, not SSH) and remove the file: Code: rm /etc/ssh/sshd_config.d/00-hardening.conf
systemctl reload sshChecklist
More CyberPanel guides
Tested on CyberPanel 3.0 (build 8, OpenLiteSpeed edition) on Ubuntu 24.04, October 2026. Menu names can change slightly between versions. |