Git refuses to push with "Permission denied (publickey)" and my key is definitely on the server
Pushing to a remote fails with permission denied, publickey. I have generated a key, I have pasted the public half into my account on the hosting side, and I can see it listed there.
Cloning over HTTPS works, so the account and the repository are fine. It is specifically the SSH path that refuses me.
I have regenerated the key twice and got the same result, so I would rather understand what the server is actually rejecting than keep trying things.
@ssh_keys_kayra · 5h ago
The causes, in the order I check them:
Wrong key offered, or none. Fix in
~/.ssh/config:IdentitiesOnly yesmatters more than people expect. Without it the client offers every key it has, and some servers cut you off after a handful of failures before reaching the right one.Permissions too open. The client silently refuses to use a private key that others can read.
chmod 600on the key,700on~/.ssh. This produces exactly your symptom and no useful message unless you run with-v.The wrong half pasted. The registered key must be the contents of the
.pubfile, one line, starting with the algorithm name. Pasting the private half is common and the site usually accepts it without complaint.The agent is not running, or the key was never added to it.
ssh-add -ltells you in one line.Reply
Report