6

I am unable to authenticate with GitHub using Git. The following error appears:

remote: remote: No anonymous write access.
fatal: Authentication failed for ...
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
VolkanUstekidag
  • 345
  • 2
  • 8
  • Did you checkout this post? There are some good answers that might help: https://stackoverflow.com/questions/60757334/git-push-from-vs-code-no-anonymous-write-access-authentication-failed – Ash Nov 12 '21 at 20:03
  • 2
    Sounds like it's not recognizing your log in. If you are using SSH make sure that you have configured you have configured the client & server to use the matching key pair: https://docs.github.com/en/authentication/connecting-to-github-with-ssh/about-ssh. – Jonathon S. Nov 12 '21 at 20:04
  • yes i tried all of them but the error persists – VolkanUstekidag Nov 12 '21 at 20:06
  • 1
    Is this error occuring for you from VS Code? Does fetching work even in VS Code, but not pushing? Then maybe my answer helps. – Alex Kimoto Nov 13 '21 at 16:44
  • Wasn't it caused by the October 2021 (1.62) release of [Visual Studio Code](https://en.wikipedia.org/wiki/Visual_Studio_Code) (or the minor versions 1.62.1 or 1.62.2)? At least there is a very strong time correlation (I got this error ***right after upgrading*** to 1.62.2, probably from 1.61. It worked perfectly fine just before the upgrade. I am on Linux, [Ubuntu MATE 20.04](https://en.wikipedia.org/wiki/Ubuntu_MATE#Releases) (Focal Fossa)). Isn't there a ***canonical Stack Overflow question*** for this? This one does not seem to be it. – Peter Mortensen Nov 16 '21 at 16:14
  • Closer to a canonical may be *[Git push from Visual Studio Code: "No anonymous write access. Authentication failed"](https://stackoverflow.com/questions/60757334/)*, as at least [one of the answers](https://stackoverflow.com/questions/60757334/git-push-from-visual-studio-code-no-anonymous-write-access-authentication-fai/69974011#69974011) addresses this October/November 2021 Visual Studio Code scandal/incident (though it isn't at all clear from the title or question). – Peter Mortensen Nov 16 '21 at 16:28
  • Can you add some context? E.g., was it using it from *within* [Visual Studio Code](https://en.wikipedia.org/wiki/Visual_Studio_Code) or the *raw* terminal command line? What version of Visual Studio Code are you at (menu *Help* → *About* )? What operating system (incl. distribution and version)? What version of Git (`git --version`)? Please respond by [editing (changing) your question](https://stackoverflow.com/posts/69948454/edit), not here in comments (***without*** "Edit:", "Update:", or similar - the question should appear as if it was written today). – Peter Mortensen Nov 16 '21 at 16:51
  • A candidate for the canonical question for this update scandal has emerged: *[fatal: Authentication failed for](https://stackoverflow.com/questions/69979522/)* (despite the unspecific title). – Peter Mortensen Nov 18 '21 at 00:18

4 Answers4

6

I had the same issue, from within Visual Studio Code.

Git pushing directly from the terminal worked, but the exact same command from the terminal within Visual Studio Code failed because of missing remote anonymous write access.

As it turned out, this was a problem with Visual Studio Code 1.62.2 for Linux. Downgrading via sudo apt install code=1.62.1-1636111026 solved the issue for the moment. You can grab the right version number with sudo apt-cache policy code.

Operating System: Elementary OS 5.1.7 (Hera)
Kernel: Linux 5.4.0-90-generic
Architecture: x86-64

The new Visual Studio Code version 1.62.3-1637137107 resolved the issue for me.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Alex Kimoto
  • 509
  • 5
  • 13
  • https://github.com/microsoft/vscode/issues/137063 – kinghat Nov 13 '21 at 18:44
  • Thanks, Alex. Unfortunately, it hits the current 1.63 Insiders build, so getting back appears to be the only way. – Martin Fridrich Nov 13 '21 at 18:51
  • 1
    Can you add some information about *how* you downgraded (others may want to use the workaround)? E.g., was it `sudo apt-get install code=1.62.1`? And Linux distribution and version. Please respond by [editing (changing) your answer](https://stackoverflow.com/posts/69951853/edit), not here in comments (***without*** "Edit:", "Update:", or similar - the answer should appear as if it was written today). – Peter Mortensen Nov 16 '21 at 16:02
  • Sure! Thanks for the heads-up, Peter! – Alex Kimoto Nov 18 '21 at 10:40
  • Downgrading vs code did not work for me. also, I can't git pushing or cloning directly from the terminal worked. – avishka Nov 19 '21 at 07:35
3

I had the same problem since after the new Visual Studio Code update. I'm running Ubuntu 18.04.6 (Bionic Beaver).

  1. Go to settings in Visual Studio Code
  2. find Git: Terminal Authentication, and deselect it
  3. run git config --global credential.helper 'cache --timeout 3600'

Now, you'll have to enter your username and password (really an authentication token - check out the GitHub documentation here for more information) the first time you push anything in a session, but your credentials will be cached for the time you selected in step 3 above. I used 10600 (three hours).

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
0

I had the same issue while coding from an old repository on a new machine and trying to push. I gave my username and password, but I was unable to authenticate.

It looks like I did "git clone" via HTTPS for this repository (didn't remember). On my new machine, I did configure SSH, but not HTTPS. That's why I got this error.

I resolved it by generating a new token in GitHub:

  • Follow the instructions for creating a personal access token (PAT)
  • When you have your new token, copy it (keep it somewhere you won't see it any more bit you'll need it next time you want to push your repository).
  • when you "git push", enter your username and, in place of the password, paste your new personal token
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
0

I was having this same issue, and most of the topics that I read, was telling the reason was a new update, to Visual Studio Code 1.62.2, and could be fixed doing the downgrade.

But I also did a new token, and it worked fine!

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131