Authentication failed when pushing to a repository on GitHub (from GitHub Desktop and command line)
Asked Answered
Q

3

9
  • I am using GitHub Desktop v2.5.7 and Git v2.29.1 on Windows 10 64 bit.
  • My GitHub account has 2FA enabled.
  • I can clone repositories from GitHub using the GitHub Desktop or command line
  • I have generated an SSL key and followed all instructions to add it locally and to GitHub
  • I have generated a personal access token and tried using this in the command line, and also my password

Problem: When I attempt to push changes to a repository I get an authentication error.

Error in GitHub Desktop:

Screenshot of error - authentication failed. Some common reasons include...

Error in command line:

With sslverify turned on:

fatal: unable to access 'https://github.com/jacquibo/neo4jDataSets.git/': SSL certificate problem: unable to get local issuer certificate

With sslverify turned off:

info: please complete authentication in your browser...
fatal: incorrect_client_credentials: The client_id and/or client_secret passed are incorrect. [https://docs.github.com/apps/managing-oauth-apps/troubleshooting-oauth-app-access-token-request-errors/#incorrect-client-credentials]
Username for 'https://github.com': [email protected]
Password for 'https://[email protected]@github.com':
remote: No anonymous write access.
fatal: Authentication failed for 'https://github.com/myusername/myrepo.git/'

I have tried:

  • all the suggestions in the error in GitHub
  • adding an SSH key locally and on GitHub (when I use ssh -i mycertname -vT [email protected] I get a permission denied message, see below)
  • adding a personal access token
  • checking origin is using HTTPS

Error using the command line to test SSL certificate:

OpenSSH_8.4p1, OpenSSL 1.1.1h 22 Sep 2020
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to github.com [140.82.121.4] port 22.
debug1: connect to address 140.82.121.4 port 22: Permission denied
ssh: connect to host github.com port 22: Permission denied

How can I fix this problem?

Only being able to edit files actually on GitHub.com is not very practical.

Quadri answered 6/11, 2020 at 14:58 Comment(0)
F
5

You need to use SSH to access the repository, not HTTPS.

Change the URL for the remote from https://xxx to git://xxx.

You can use the green button towards the right side of the GitHub repository code page to help you get the correct URL. Change from:

HTTPS URL

to

SSH URL

The other thing you need to do is make sure you have an up-to-date local installation of Git. You may run into errors if you have an old version of Git installed.

Felice answered 6/11, 2020 at 15:30 Comment(0)
G
0

It's because of not having an SSH key in your GitHub account. Follow the documentation to install SSH key to your GitHub account.

Generating a new SSH key and adding it to the ssh-agent

Gradely answered 3/2, 2021 at 17:5 Comment(0)
C
0

File > options > Sign out of github

then sign in again

The problem will disappear

Cotten answered 11/9 at 8:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.