Skip to content
Server and cPanel3 min read

Fixing "Permission denied (publickey)" in SSH

Permission denied (publickey).

Short answer

The server only accepts key authentication and found no authorized public key matching the one your computer offered. Create a key with ssh-keygen -t ed25519, add the public half to the server (in cPanel: SSH Access → Manage SSH Keys → Authorize), and connect with the correct account username.

ArabyHost teamLast updated: ShareWhatsAppXLinkedIn
Contents
  1. Causes
  2. Diagnose before changing anything
  3. How to fix it
  4. Prevention
  5. On ArabyHost

Getting this message means the network is fine: your computer reached the SSH service and only authentication failed. The list in parentheses is what the server accepts, and (publickey) on its own means password login is disabled, so you need a working key.

[email protected]: Permission denied (publickey).

Causes

  • The public key isn’t in ~/.ssh/authorized_keys on the server, or you imported it in cPanel and never clicked Authorize.
  • Wrong username: on cPanel hosting it’s the account’s cPanel username, not your email or the domain.
  • Your computer offers a different key: ssh only tries default files (such as id_ed25519 and id_rsa) unless you pass -i.
  • ~/.ssh or authorized_keys on the server has loose permissions, so SSH ignores it for security.
  • An old tool signs with ssh-rsa (SHA-1), which OpenSSH 8.8 and later disable by default.
  • The public key was pasted with extra line breaks or missing characters.
  • With GitHub: the key isn’t added to your account or the repository.

Diagnose before changing anything

ssh -v [email protected]

Look for Offering public key: to see which key was sent. If that line never appears, no key is being offered. If it appears and is followed by Authentications that can continue: publickey, the server doesn’t recognise that key.

How to fix it

1. Create a key if you don’t have one

ssh-keygen -t ed25519 -C "my-laptop"

This writes ~/.ssh/id_ed25519 (the private key, which never leaves your machine) and ~/.ssh/id_ed25519.pub (the public key you give the server). The same command works in PowerShell on Windows 10 and 11.

2. Add the public key in cPanel

  1. Open cPanel → Security → SSH Access → Manage SSH Keys.
  2. Click Import Key, name it, paste the contents of id_ed25519.pub into the public key box, then Import.
  3. Go back, find the key under Public Keys, click Manage, then Authorize.

3. Connect with the right key and user

ssh -i ~/.ssh/id_ed25519 -p 22 [email protected]

To skip the flags next time, add this to ~/.ssh/config on your computer and connect with ssh myhost:

Host myhost
    HostName example.com
    User cpuser
    Port 22
    IdentityFile ~/.ssh/id_ed25519
    IdentitiesOnly yes

4. Fix permissions

On the server:

chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

On your computer, the private key must be readable only by you (chmod 600 ~/.ssh/id_ed25519), or SSH refuses it with UNPROTECTED PRIVATE KEY FILE!.

With GitHub

Add the public key under Settings → SSH and GPG keys, then test with ssh -T [email protected]. For a server that pulls code, use a separate key added to the repository as a deploy key.

Prevention

  • One key per device, protected with a passphrase and loaded into ssh-agent.
  • Delete keys you no longer use from cPanel.
  • Don’t retry over and over with a bad key: repeated failures can get your IP blocked for a while, and the error then turns into Connection refused.

On ArabyHost

SSH is available only on the AI/Developer plans, on port 22, inside a CageFS-jailed environment. We recommend key login, as described in the SSH keys guide and what an SSH key is. Open cPanel with one click from the Araby Panel to import and authorize your key. If the firewall blocks your IP after failed attempts, contact support to lift the block. Once you’re in, you can run Claude Code or Codex on the server over SSH, as covered in the SSH access guide.

FAQ

Does this error mean my password is wrong?

No. If the parentheses contain only publickey, the server doesn't accept passwords at all. The key your computer offered isn't authorized, or the username is wrong.

I added the key in cPanel and still get the error. Why?

Usually the key was imported but never authorized, or your computer is offering a different key. Point to the file with -i and check the Offering public key line in ssh -v output.

Is this the same error with GitHub as with my hosting server?

Same message, different place to fix it. For GitHub, the public key must be added to your account or to the repository as a deploy key; for your host, it must be authorized on the server account.

Useful? Share it with someone who needs it:WhatsAppXLinkedIn

Read next

Ready to put your idea online?

Fast, isolated hosting, support that understands you, and an AI assistant that fixes problems with you.