Skip to content

/errors/ssh/permission-denied-publickey

Permission denied (publickey) with ssh

The commands on this page have not been executed by our verification runner yet.updated 2026-10-20
tool
OpenSSH
exit code
255
versions
OpenSSH 8.x – 10.x
os
linux, macos, windows

Permission denied (publickey). means the SSH server only allows public-key authentication and rejected every key your client offered; ssh exits with status 255. The server must have your public key in the target user's ~/.ssh/authorized_keys (or in your GitHub or GitLab account), and your client must offer the matching private key.

Diagnose with -v

bash
ssh -v user@server.example.com

In the output, look for:

  • Offering public key: … — the keys the client tries.
  • Authentications that can continue: publickey — the server accepts only keys.
  • Server accepts key — the key is authorized; if it never appears, none of the offered keys is.

Fixes

Offer the right key:

bash
ssh -i ~/.ssh/id_ed25519 -o IdentitiesOnly=yes user@server.example.com

Install your public key on the server (password login must still work for this step):

bash
ssh-copy-id -i ~/.ssh/id_ed25519.pub user@server.example.com

Fix permissions on the server. sshd ignores authorized_keys when the directory or file is writable by others:

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

Use the right user. Cloud images use a default user (ubuntu, ec2-user, admin); GitHub and GitLab always use git.

Replace old key types. OpenSSH 10.0 removed DSA support entirely. Create an Ed25519 key with ssh-keygen -t ed25519.

FAQ

How do I test SSH authentication with GitHub?

Run ssh -T git@github.com. On success GitHub greets you by user name and closes the connection, because it does not provide a shell.

Sources