Skip to content
MtrXTools

Permission denied (publickey)

The server rejected every SSH key you offered

Seen in OpenSSH client, git over SSH (GitHub, GitLab, Bitbucket), cloud VMs

The SSH server only accepts key authentication and none of the keys your client offered are authorised for that user.

Common causes

  • Your public key is not added to the account (GitHub settings, or ~/.ssh/authorized_keys on the server).
  • The client is offering the wrong key, or the key is not loaded in ssh-agent.
  • Wrong username: e.g. ubuntu vs ec2-user on cloud images, or anything other than git@ for Git hosts.
  • Server-side permissions on ~/.ssh or authorized_keys are too open, so sshd ignores them.

How to fix it

  1. Run ssh -v user@host to see which keys are offered and whether one is accepted.
  2. Add your key to the agent (ssh-add ~/.ssh/id_ed25519) or set IdentityFile for the host in ~/.ssh/config.
  3. For GitHub, test with ssh -T git@github.com after adding the public key to your account.
  4. On the server: chmod 700 ~/.ssh and chmod 600 ~/.ssh/authorized_keys.

Got a different message? Paste it into the error explainer.

Related errors

All 31 Dev tools & SSH errors