~/.ssh/authorized_keys, or that folder has the wrong permissions. Run ssh -v to see which key is offered, then fix the server side from the VNC console.
Before you start
- The text in brackets lists the login methods the server still offers.
(publickey)alone means password logins are switched off, so typing a password can’t work. - For fixes on the server, use the VNC console on a VPS. If you also forgot the password, reset the root password first. On a dedicated server, open a ticket for KVM/IPMI access.
- Commands use
sudo. As root, leave it out.
Step 1: See what your client sends
- No
Offering public keyline: your client has no key to offer. Point to it with-i(Cause 2). - A key is offered but no
Server accepts keyfollows: the server doesn’t know that key, or ignores it (Causes 2 to 4).
Cause 1: Wrong username
The key is installed for one user only. Logging in asroot when the key belongs to alex, or the reverse, fails.
Fix: use the user the key was set up for:
root is refused but other users work, check PermitRootLogin in /etc/ssh/sshd_config and the files in /etc/ssh/sshd_config.d/. The value no blocks root completely. See disable root login.
Cause 2: Your client offers the wrong key
SSH tries your default keys (such as~/.ssh/id_ed25519). A key saved elsewhere, or with another name, isn’t used automatically.
Fix: name the key:
IdentityFile so you don’t have to type it. In PuTTY, select the .ppk file under Connection > SSH > Auth > Credentials. PuTTY can’t use an OpenSSH key directly: convert it with PuTTYgen first.
Cause 3: The public key isn’t in authorized_keys
Check on the console (replacealex with your user):
cat ~/.ssh/id_ed25519.pub). The whole line must match, on one line.
Fix: add the public key, one key per line:
root, the file is /root/.ssh/authorized_keys. To manage keys through the panel instead, see manage SSH keys.
Cause 4: Wrong ownership or permissions
OpenSSH ignoresauthorized_keys if other users could change it. The SSH log shows:
- Ubuntu / Debian
- AlmaLinux / Rocky
Cause 5: You wanted to log in with a password
If you don’t have a key at all, the server needs password logins. Don’t switch them on permanently on a public server. Instead, log in on the console, create a key pair on your computer and add the public key as in Cause 3.How to check it worked
Frequently asked questions
Can I just copy my private key to the server?
No. Only the public key (the.pub file) goes on the server. The private key stays on your computer.
It worked yesterday. What changed?
Common causes are a rebuild (which replacesauthorized_keys), a new computer without your old key, or a chmod -R 777 on the home folder. Check the log in Cause 4 first.
Why does ssh-copy-id fail with the same error?
ssh-copy-id needs a working login to copy the key, usually a password. With password logins off, add the key through the console instead.
Related guides
VPS and dedicated server guides
Every guide in this section.
Create and use SSH keys
Make a key pair and install it.
Use PuTTY
Keys and settings in PuTTY.
SSH connection refused
When SSH doesn’t answer on the port.
Host key verification failed
The other common SSH warning.
Checked against the official OpenSSH sshd manual (AUTHORIZED_KEYS FILE FORMAT) and Ubuntu’s OpenSSH server guide on 4 November 2026; the error, the
ssh -v output, the wrong-key case and the “bad ownership or modes” log line were reproduced and fixed on Ubuntu 24.04 LTS (OpenSSH 9.6). The SELinux step was not tested.Need Extra Help?
If you encounter any issues, our support team is ready to assist:- Live Chat: Quick assistance via our website.
- Support Ticket: Open a Ticket
- Discord: Join our Community
- Email: support@freakhosting.com
Last Updated: November 2026