Login failed to GitHub [duplicate]

While trying to push a code into GitHub from external command line, on running the command “git push -u origin main” there pops up a window so that we may login and confirm our identity to GitHub but after filling username and password the command line shows “Logon failed” what might be the possible reason for this and what should i do to resolve the issue

  • 1

    This could be a problem due to a wide range of reasons. You could first of all check for your credentials are they correct or not. I would ask you to edit the .git configuration file in your home directory. Moreover, if you are using vscode try and use some GUI interface for git like gitkraken or git lens. you could also sign in in vscode using the github and then try command line push from the repository; Liike open the repo in vscode and then push. This might resolve your issue of you have ore problem do comment or mention ore details in the question.

    – 

  1. Type your GitHub username when prompted
  2. Instead of your password, you need to type the Personal Access Token. To get one, go to your GitHub account —> Settings —> Developer Settings —> Personal Access Tokens —> Pick any one and generate the token(use classic for most cases), here you can set the deadline too for it to expire

GitHub made a security-oriented decision by shifting away from using passwords for command line logins and introducing personal access tokens. Passwords, with their potential exposure in logs and difficulties in managing access scopes, posed security risks. Personal access tokens offer a more secure alternative by being user-specific and purpose-bound. They allow users to specify precise permissions for different actions, like read-only access or code commits. If one token is compromised, it can be revoked individually without affecting the entire account, significantly enhancing security measures and granting users more control over their GitHub interactions through the command line.

Leave a Comment