0

I've been pushing my repos just fine, then enabled two factor authentication and can no longer push.

I created an SSH key and added it to my GitHub account, then created a config file in ~/.ssh/config and added the following.

Host *
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/id_rsa

Host github.com
    HostName github.com
    User [myusername]
    IdentitiesOnly yes

Yet when I push a repo it's asking for my GitHub username and password, and after entering them then tells me I don't have authorization.

remote: Invalid username or password.

I even tried using my auth backup code for the password, but no good.

Since I'm on macOS Catalina I tried

eval "$(ssh-agent -s)"
ssh-add -l -E md5

Which resulted in the "This agent has no identities" message. So of course I did the following

ssh-add ~/.ssh/id_rsa

And tried it again and it's still the same. I'm basically stuck in a loop of nothing working and don't know what to do!

timgavin
  • 4,215
  • 4
  • 30
  • 44
  • Just to confirm, your `git remote -v` does not have a HTTPS URL, right? – GoodDeeds Apr 25 '20 at 02:39
  • It actually does. `https://github.com/myusername/myrepo.git (push)` – timgavin Apr 25 '20 at 02:41
  • You need to change that for using SSH. See [this](https://help.github.com/en/github/using-git/changing-a-remotes-url#switching-remote-urls-from-https-to-ssh). – GoodDeeds Apr 25 '20 at 02:42
  • Thank you! Please put that as an answer so I can give you credit. – timgavin Apr 25 '20 at 02:46
  • Good to know it worked. However similar questions have been asked several times, so perhaps it is better to close as a duplicate. You could accept the duplicate target instead. – GoodDeeds Apr 25 '20 at 02:48
  • 1
    Yep, that did it. I spent over an hour trying to find a solution; I guess I just wasn't asking the question properly. Thanks again! – timgavin Apr 25 '20 at 02:53

0 Answers0