r/github • u/ProperAssociation322 • Aug 12 '26
Discussion Locked out of GitHub due to 2FA after changing phone and laptop — still have working Git credentials on an old Windows PC. Any way to recover?
Locked out of GitHub due to 2FA after changing phone and laptop — still have working Git credentials on an old Windows PC. Any way to recover?
I’m currently locked out of my GitHub account because of 2FA and I’m trying to figure out if there is any legitimate way to recover it.
Here’s the situation:
- GitHub username: `ronit450`
- I recently changed my laptop from Windows to Linux.
- I also recently changed my phone.
- My old phone had the authenticator app that I used for GitHub 2FA, but I no longer have access to it.
- I don't have my GitHub recovery codes.
- I still have full access to the email address associated with the account.
- I know my GitHub username and normal account password.
- Previously, I remember being able to receive a verification code through email in some situations, but that option is no longer available when I try to log in.
- GitHub's account recovery options haven't worked for me.
I contacted GitHub Support, and they told me they cannot bypass or disable 2FA and pointed me toward the normal account recovery process.
**However, I found an old Windows laptop that I previously used for GitHub.**
On that machine, I found that Git Credential Manager still has a GitHub credential stored:
Target: LegacyGeneric:target=git:https://github.com
User: ronit450
Local machine persistence
and it successfully authenticated and downloaded from the repository without asking me for a username, password, or token.
So I know there is currently a working GitHub credential stored on this old Windows machine.
I have not deleted, modified, or extracted the credential.
My question is:
Is there any legitimate way to use this existing authenticated Git credential/session to recover access to my GitHub account or establish ownership through GitHub's official recovery process?
Could the credential stored by Git Credential Manager be a PAT/OAuth credential that could help with account recovery?
I'm not trying to bypass GitHub's security or disable 2FA. I just want to recover my own account, and I can provide whatever legitimate ownership information is required.
Any advice from people who have dealt with a similar situation would be greatly appreciated.
Please don't ask me to post the actual credential/token — I won't share that publicly.
1
u/ProperAssociation322 Aug 12 '26
The old windows machine is basically AWS instance where l login my git not using ssh but probably https. So when I try to login like verifying ssh on that instance it says it failed
1
u/ProperAssociation322 Aug 12 '26
But i can still do git pull and push on that machine
1
u/cowboyecosse GitHub staff Aug 13 '26
I’d check that machine for the recovery codes. Where could they have been saved to when 2FA was set up?
1
u/Ok_Woodpecker_9104 Aug 12 '26
the thing sitting in GCM is almost certainly the OAuth token from github's git-credential OAuth app, not your password. read it and check its scopes before you do anything else, that decides whether any of this is useful.
on the old windows box:
then take the password value and:
look at the x-oauth-scopes header that comes back. the git-only token usually shows repo, gist, workflow and nothing else. it cant turn off 2FA either way, that needs a real web session, so support is right about that part.
the path that actually matters is github.com/account_recovery. that flow can verify you with an ssh key already registered on the account and it does not care about your authenticator app at all. so go look in %USERPROFILE%.ssh on that old machine for a key you registered back then. if one is there and still on the account, thats your way in, not the https credential.
if the token scopes do include write:public_key or admin:public_key, you can POST a new key to /user/keys with it and then use that key for the recovery challenge. if the scopes dont include it, the token cant add a key and this dead ends.
one warning: dont touch that credential entry, dont run git credential reject, and dont let anything on that machine try to re-auth. GCM will happily overwrite the entry and then you have nothing left to work with. copy it out somewhere safe first.