Archive for the ‘github’ Category

“git push” keeps asking password [Deprecating password authentication]

December 1, 2022 Leave a comment

Today morning while pushing the changes to the github repository, I was constantly asked to provide the username and password at the console.

Despite passing the correct username and password, I was not able to push the changes and rather message below

It was working fine till yesterday night and hence was wondering what could have caused the issue. I started looking into the access token in the Github and saw that the one I was using till last night was expired and hence seeing the issue.

Password-based authentication for Git is deprecated (as evident from the screenshot above as well) and you should make the push based on the token authentication. GitHub has personal access token (PAT), to use in place of a password with the command line or with the API. Below is how to generate the token and use it.

Create a token in Github

  • Login to GitHub and navigate to ‘Settings’ from within your profile
  • Click on Developer Settings. This will take you to GitHub Apps page. Navigate to “Personal access token” section.
  • Click on Personal Access Token –> Token (classic).
  • You will find all your tokens (active or expired). Here I found my token to be expired today and hence I was able to run the”git push” command successfully till last night.
  • Click on ‘Generate new token’
  • Make sure you note down the ‘Personal Access token’. It won’t be shown again and if you didn’t note it down, there is no way but to create a new one.
  • Use the newly created token to use the ‘git push’ command.
    • $ git push https://<Personal-Access-Token><Your-Github-UserName>/<Name-of-your-repository>

Hope this helps. Happy reading.

~Anand M