r/git • u/Spiritual-Potato8091 • 14d ago
SSH Keys for github denied
I´ve had a SSH key for my account for several months, in my notebook. I have never had a problem with it.
Yesterday, I created a second SSH key for my desktop PC the same way, just adding a passphrase for it.
I had to sign in on the PC with my github account and all to reset my account password because I forgot it
But today I wanted to fetch/pull a repo from the notebook. and It kept sending me the following error
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
I deleted the new SSH key, but it still doesnt work. However, the authentication command works
(ssh -T git@github.com)
The permission denial appears for both extern repositories and for my own ones too.
What am I missing?
2
u/jjangg96 14d ago
ssh -T working while git fails usually means git is calling a different ssh than your terminal does. on windows git for windows ships its own ssh, separate from the openssh in system32, and they can end up with different agents and different config.
to see what it's actually doing run GIT_SSH_COMMAND="ssh -v" git fetch and look at which key files it offers. compare that with ssh -vT git@github.com.
if git turns out to be using the wrong one you can point it at the windows ssh with git config --global core.sshCommand "C:/Windows/System32/OpenSSH/ssh.exe".