2

I was using an SSH key for github for a while, I've now switched to a new account and Git is still trying to use my old SSH key. Here's what I get when trying to push:

remote: Permission to ***REPO*** denied to ***OLD USERNAME***
fatal: unable to access ***REPO***: The requested URL returned error: 403

My .gitconfig file has the correct email and name.

My ~\.ssh\config file reads as follows:

Host github.com
  IdentityFile ~/.ssh/id_ed25519   ***The correct key***
  IdentitiesOnly yes

I deleted the old key files.

When I run ssh-add -l, the only key listed is the correct one.

I also uninstalled and reinstalled Git.

Does anyone have any insights? Is there a global config file for ssh-agent somewhere or something? I have no idea what to do, the only next step I can think of is literally reinstalling Windows.

1
  • 403 is an https error code, which means you're not using ssh in the first place. Commented Mar 10, 2022 at 22:12

1 Answer 1

1

First, make sure you are using an SSH URL:

ssh://[email protected]/<newUser>/myproject
# or
[email protected]:<newUser>/myproject

So:

cd /path/to/local/repo
git remote -v

If you were to use an HTTPS URL, then it is possible the old user name/password is cached by the credential helper (check the value of git config --global credential.helper)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.