ssh · Git
The message
git@github.com: Permission denied (publickey).
What it means
ssh reached the server but offered no key the server is willing to accept — this is authentication, not networking. It happens when you have not generated a key, or you have one but never added it to ssh-agent, or the public key is not registered on your account with that host. ssh-add ~/.ssh/id_ed25519 loads the key into the agent for this session, and ssh -T git@github.com reports which key was tried and who you are recognised as. Both commands only read; there is nothing to lose.
The fix
ssh-add ~/.ssh/id_ed25519- Printed by
- ssh
- Git
- 29
Almost every git error is a refusal that means "doing that from this state would lose something"; fatal: means git stopped without changing anything, and the hint: lines under the first line usually carry the actual remedy.
Reading an error message
- Read from the first line down. The lower you go the more it is about the tool’s internals; the cause is usually at the top.
- If there is a file and a line number, start there — not the top stack frame, but the topmost line that names a file you wrote.
- Search the message verbatim, but strip your own paths and variable names first; those are what stop the search from matching.
- The same condition is worded differently across tool versions. If results look wrong, add the version number to the query.
- Before pasting a fix, check what it throws away. Some of these cannot be undone.
Common questions
Q. What does “git@github.com: Permission denied (publickey).” mean?
ssh reached the server but offered no key the server is willing to accept — this is authentication, not networking. It happens when you have not generated a key, or you have one but never added it to ssh-agent, or the public key is not registered on your account with that host. ssh-add ~/.ssh/id_ed25519 loads the key into the agent for this session, and ssh -T git@github.com reports which key was tried and who you are recognised as. Both commands only read; there is nothing to lose.
Q. How do I fix it?
ssh-add ~/.ssh/id_ed25519 — before running it, check the explanation above for what this command discards.
Q. Which tool prints this?
ssh. It sits under Git, and the message runs to 4 words.