gitgithubgit-bashgit-credential-managergithub-cli

Getting prompted with a GitHub Login Interface whenever I try to push to repo


this happened around 3 weeks ago, when they said https connections to GitHub would be removed. That's when this Login UI started popping whenever I tried to push, even though I provided the correct username and password, it said it's incorrect. Then prompted me to type it in bash/terminal, still saying it's incorrect.

I setup a SSH key and everything was going well, until I tried to push and the same happened again.

Installed GitHub CLI, setup a brand new repo to test this out, and the problem still persists! Have been searching all over docs and on the internet for the past 3 hours, it's driving me nuts.

Would like you to provide me with a solution guys. Thanks

EDIT: I'm running git version 2.26.0.windows.1

output when git remote -v is typed:

origin  https://github.com/marjotoska/website-mock-test.git (fetch)
origin  https://github.com/marjotoska/website-mock-test.git (push)

EDIT2:

git push
fatal: The current branch main has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin main

git push --set-upstream origin main
Logon failed, use ctrl+c to cancel basic credential prompt.

Then the login UI appears just like this, and even though username and password provided are correct, it doesn't log me in.

After that UI fail, login from cmd also fails:

Username for 'https://github.com': marjotoska
Password for 'https://marjotoska@github.com':
remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.
fatal: Authentication failed for 'https://github.com/marjotoska/website-mock-test.git/'

I generated SSH key the way it was intended in the docs: https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent


It makes no sense whatsoever that login fails twice, also tried logout->login from the browser and it works just fine with the same credentials. Is there something to be done here?

EDIT3: The website (https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations) GitHub devs point to:

What you need to do today. For developers, if you are using a password to authenticate Git operations with GitHub.com today, you must begin using a personal access token over HTTPS (recommended) or SSH key by August 13, 2021, to avoid disruption. If you receive a warning that you are using an outdated third-party integration, you should update your client to the latest version.

I'm using SSH over HTTPS, and the problem still persists.

EDIT4: Login with Personal access tokens works!!!

From Github:

Personal access tokens function like ordinary OAuth access tokens. They can be used instead of a password for Git over HTTPS, or can be used to authenticate to the API over Basic Authentication.

PAT is treated as a password, and I used it in place of my password, which pushed the local repo to the remote one

Logon failed, use ctrl+c to cancel basic credential prompt.
Username for 'https://github.com': marjotoska
Password for 'https://marjotoska@github.com':
Enumerating objects: 27, done.
Counting objects: 100% (27/27), done.
Delta compression using up to 8 threads
Compressing objects: 100% (25/25), done.
Writing objects: 100% (27/27), 106.63 KiB | 8.20 MiB/s, done.
Total 27 (delta 3), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (3/3), done.
To https://github.com/marjotoska/website-mock-test.git
 * [new branch]      main -> main
Branch 'main' set up to track remote branch 'main' from 'origin'.

SOLVED!


Solution

  • Support for password authentication was removed on August 13, 2021 for security reasons by the developers. They recommend to use a personal access token instead.

    To create a token:

    1. From your GitHub account > profile picture > settings
    2. Developer settings from the left sidebar > Personal Access Tokens
    3. Generate new token.

    To use the token:

    Replace your password with the token when prompted to login/authenticate. Note: PAT doesn't work with UI, but it does from cmd prompt

    To cache your credentials and stop the prompt appearing every time you commit:

    gh auth login
    

    Follow the prompts > set HTTPS as the preferred protocol > paste PAT in the very last step.

    Now you're hooked and ready to go

    Links: https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/

    https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token

    https://docs.github.com/en/get-started/getting-started-with-git/caching-your-github-credentials-in-git

    https://cli.github.com/manual/gh_auth_login