Fatal authentication failed for ошибка

I started experiencing this issue on Visual Studio Code in Ubuntu 20.04 yesterday.

I did not make any changes to my GitHub credentials, neither did I change anything in the project, but I run any git command to communicate with my remote branch like:

git pull origin dev

I get the error below:

remote: Repository not found.
fatal: Authentication failed for ‘https://github.com/MyUsername/my-project.git/’

Here’s what worked for me:

I tried recloning the project and then running the git pull command but it did not work.

git clone https://my-git-url

I tried setting my credentials again using the below commands but still no luck:

git config --global user.email "email@example.com"
git config --global user.name "John King"

I tried removing the remote repository and re-adding it using the below commands, but still no luck:

git remote remove origin
git remote add origin https://my-git-url

Finally, I decided to try using my default Ubuntu terminal and it worked fine. My big guess is that it’s a bug from Visual Studio Code from the last update that was made some few hours before then (See the screenshot that shows that a Release was done on the same day that I was having the issue). I mean I set up Visual Studio Code using snap, so probably it might have been updated in the background a few hours before then.

enter image description here

Hopefully, they will get it fixed and git remote operations will be fine again.

Git is a popular version control software that every developer should know how to use. But sometimes, it pops out strange errors that confuses even seasoned users. If you are seeing “Authentication failed” whenever you try to use git push command, this short article is going to help you solve this error message.

The “fatal: Authentication failed” error message indicates that the existing authentication method you have been using on your repository has become obsolete/outdated. The full error message may look like this

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/user/example-project.git/'Code language: JavaScript (javascript)

Or if you’re pushing to your remote repository via HTTPS, the error message may look like this

If you enabled two-factor authentication in your Github account you won't be able to push via HTTPS using your accounts password. Instead you need to generate a personal access token. This can be done in the application settings of your Github account. Using this token as your password should allow you to push to your remote repository via HTTPS. Use your username as usual.

Usually, the “Authentication Failed” error happens if you recently enabled 2-Factor Authentication on your GitHub account and uses HTTPS to push/pull in Git at the same time. GitHub deprecates the password authentication method from August 13, 2021 to favor more secure way of authentication. In this article, we will show you several possible ways to get around the “fatal: Authentication failed” problem.

Switch to SSH protocol in Git

As being said earlier, Github is no longer allow authenticating via HTTPS URLs once 2-Factor Authentication (2FA) enabled. Git with HTTPS uses public-key encryption-based authentication for doing every action like git push, git clone, git fetch and git pull, etc. Meanwhile, SSH protocol allows Git to securely transfer repository data over the internet.

In order to quickly fix “fatal: Authentication failed”, you can remove the existing origin (which is something like https://github.com:user/repo.git) and re-add a [email protected]:user/repo.git URL to instruct Git to use SSH instead. Run the following command to do so:

git remote -v
git remote remove origin
git remote add origin [email protected]:user/repo.git

If you didn’t set up the necessary private keys for Git, running the commands above will end up with an error message. You may need to consult access Github repositories using SSH keys and Connecting to GitHub with SSH for instructions on adding private keys.

git remote add origin with SSH

Create a PAT (Personal Access Token)

When you connect to a GitHub repository from Git, you’ll need to authenticate with GitHub using either HTTPS or SSH. Alternatively, you can use Github CLI with the command gh auth login. All of these authentication method requires a PAT (Personal Access Token) that is a more secure alternative to passwords. Follow the instructions below to create a PAT :

First, login to your account. In the upper right corner of the page, look for your avatar, click it and select Settings.

In the Settings page, choose Developer settings > Developer settings > Personal access tokens in the left sidebar.

Personal access tokens

Create a PAT (Personal Access Token)

When you connect to a GitHub repository from Git, you’ll need to authenticate with GitHub using either HTTPS or SSH. Alternatively, you can use Github CLI with the command gh auth login. All of these authentication method requires a PAT (Personal Access Token) that is a more secure alternative to passwords. Follow the instructions below to create a PAT :

First, login to your account. In the upper right corner of the page, look for your avatar, click it and select Settings.

In the Settings page, choose Developer settings > Developer settings > Personal access tokens in the left sidebar.

Click Generate new token in order to create a new PAT. You will be able to name the token, set its expiration date and its scope. For a token that specifically for managing repositories, you should limit the scope to repo.

Limit PAT scope

Finally, click Generate token. You would be redirected to another page which shows you the newly created token. Remember that the token will only be shown once. If you lost the token, you have no way to recover it but to re-generate a new one.

Treat your tokens like passwords and keep them in a secure place. The token should be stored in an environment variable instead of hardcoding them into your programs/applications source code.

Once you’re done creating a token, you have to reset the old password authentication by running the following command.

git config --global --unset credential.helperCode language: PHP (php)

You may also need to update your repository to change the protocol from HTTPS to native SSH

git remote -v
git remote remove origin
git remote add origin [email protected]:user/repo.git

Disable Github 2-Factor Authentication

If you recently enabled 2-Factor Authentication(2FA) on your GitHub account right before the “Authentication Failed” error pops up, you can try disabling it to quickly fix the problem.

However, remember that disabling 2FA significantly increase the risk of your account to be compromised. Also, If you’re a member, billing manager, or outside collaborator to a public repository of an organization that requires two-factor authentication and you disable 2FA, you’ll be automatically removed from the organization, and you’ll lose your access to their repositories. In order to regain access to the organization, you have to re-enable 2FA and re-apply to the organization.

To disable 2FA for an account, you need to log into it, then click your profile photo in the upper right corner and select Settings.

Settings icon in the user bar

Then, select Account Security in the left sidebar and click Disable in Two-factor authentication section.

Disable two-factor authentication button Github

Remove saved credentials on Windows

Windows users may beed to change your login or password of the Git service account stored in Windows Credential Manager.

First, you need to search for Windows Credential Manager from the Start menu. Usually it is placed in Control Panel if you use Windows 7 and Settings on newer Windows versions.

On the Credential Manager window, click on Windows Credentials tab and look for anything that starts with git: or ada:. In order to remove them, you would have to click each of them to open the details view and click Remove.

You may also need to remove them from Generic Credentials, too.

Remove saved credentials from Windows Credential Manager

We hope that the information above helps you solve the “fatal: Authentication failed” error message in Git. You may want to check out our other guide on fixing other popular Git issues such as Git : how to accept all current/incoming changes, How to clone a private repository in Github or How to access GitHub from inside China.

thumb

После включения двухфакторной аутентификации в моей учётной записи GitHub, когда Я запускаю команду Git git push она выдаёт следующее сообщение об ошибке:

$ git push
Username for 'https://github.com': Username
Password for 'https://Username@github.com':
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/username/repository.git/'

Что вызывает эту ошибку

Это сообщение об ошибке говорит само за себя. Это означает то, что мы пытаемся использовать неверное имя пользователя или пароль. Но Я уверен в том, что использую правильное имя пользователя и пароль. В моём случае, это произошло со мной после того, как Я включил двухфакторную аутентификацию (2FA) в моём аккаунте GitHub. Поэтому я знаю о том, что вызвало это сообщение об ошибке.

Как это решить

Как только мы узнали о том, что вызывает сбой работы git, мы можем использовать это для решения проблемы. Это действительно простой процесс. Для того, чтобы решить эту проблему, нам нужно всего лишь создать личный token доступа GitHub и использовать его вместо нашего пароля GitHub и двухфакторного кода аутентификации. Теперь пошаговое руководство.


Создание token доступа к персональному доступу GitHub.

В правом верхнем углу любой страницы нажмите на фотографию своего профиля, затем нажмите Settings.

В левой боковой панели нажмите Developer settings.

В левой боковой панели нажмите Personal access tokens.

Нажмите Generate new token.

Дайте вашему token имя (любое имя описывающее цель его создания).

Выберите области действия или разрешения, которые вы хотите предоставить этому token. Для того, чтобы использовать ваш token для доступа к репозиториям из командной строки, выберите repo.

Нажмите Generate token.

Скопируйте token в буфер обмена. По соображениям безопасности, после ухода со страницы, вы не сможете снова увидеть token.

Как исправить: fatal: Authentication failed for https://github.com/

Примечание! Относитесь к своим token’ам, как к паролям и держите их в тайне (если вы не хотите, чтобы другие люди использовали API от вашего имени). При работе с API, используйте token’ы как переменные окружения вместо hardcoding их в ваши программы.


Использование token в командной строке.

Как только у нас появился token, мы можем ввести его вместо нашего пароля при выполнении операций Git через HTTPS. Просто введите свой token после запроса пароля, а затем смотрите на то, как происходит магия…

Username: your_username
Password: your_token

Примечание! Token’ы личного доступа могут использоваться только для операций HTTPS Git. Если ваш репозиторий использует удалённый URL SSH, вам нужно будет переключить управление с SSH на HTTPS.

Примечание! Если вам не будет предложено ввести имя пользователя и пароль, ваши учетные данные могут быть кэшированы на вашем компьютере. Вы можете обновить свои учетные данные в Keychain заменить старый пароль на token.

Заключение

Вот и всё, готово. Теперь проблема возникшая после включения двухфакторной аутентификации в учётной записи GitHub устранена. Так просто, не так ли?

Если у вас возникают проблемы в устранении этой проблемы с помощью приведенной выше инструкции, но вы смогли решить эту проблему любым другим способом, пожалуйста, опишите его в разделе комментариев ниже. Спасибо!

Я надеюсь, что эта статья помогла вам узнать, как решить проблему которая возникла после включения двухфакторной аутентификации в учётной записи GitHub. Если эта статья помогла вам решить проблему, пожалуйста, оставьте комментарий :smiley:

Спасибо за прочтение!

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.

Already on GitHub?
Sign in
to your account

Closed

jasabalete opened this issue

Dec 9, 2015

· 41 comments

Assignees

@isidorn

Спасибо за прочтение!

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.

Already on GitHub?
Sign in
to your account

Closed

jasabalete opened this issue

Dec 9, 2015

· 41 comments

Assignees

Labels

bug

Issue identified by VS Code Team member as probable bug

verified

Verification succeeded

Comments

@jasabalete

I have configured my git remote like this:

[remote "origin"]
    url = http://MY-HOST.../branch-locatlocator-select-ui.git

And when i do a push show me an error:

fatal: Authentication failed for 'http://MY-HOST.../branch-locatlocator-select-ui.git/'

Why Visual Studio Code add the final slash? :(

@joaomoreno
joaomoreno

added
the

bug

Issue identified by VS Code Team member as probable bug

label

Dec 9, 2015

@joaomoreno

Oh that’s terrible, sorry for that!

@joaomoreno

I assume a simple git push from the command line works, right?

@jasabalete

Yes, «git push» from the command line works

@joaomoreno

Git seems to do this, not VS Code. Here’s a snippet from the command line:

$ git config remote.origin.url
https://github.com/joaomoreno/node-libarchive.git
$ git push
Username for 'https://github.com': joaomoreno
Password for 'https://joaomoreno@github.com':
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/joaomoreno/node-libarchive.git/'

Is your host by any chance GitHub or BitBucket? Which command line exactly are you using?

Closing as dupe of #490. Will reopen if further information reveals this to be an independent issue.

@jasabalete

My repo is GitLab CE

$ git config remote.origin.url
http://ISLINGIP01.scisb.isban.corp/portales-branch-locator/branch-locator-select-ui.git

The URL with the final slash only apears in VSCode and if i put this URL in Chrome for example return ERR_TOO_MANY_REDIRECTS

Why VSCode connect with the remote and add a final slash?

@jasabalete

Note: the error is in VSCode when I do a push or a pull in the Git feature

@joaomoreno

Is there any way you can set up a repository in that same server and give me credentials to access it so I can try to repro?

@jasabalete

the same error in gitlab.com repository.

 fatal: Authentication failed for 'https://gitlab.com/jasabalete/test-project.git/'

I invite you in a public repository for testing and «master» role :)

@jasabalete

I do this:
1 — Create a public repository
2 — git clone https://blah/blah.git
3 — Open the folder with VSCode
4 — Commit and push a file
5 — VSCode add final slash «/» and error
fatal: Authentication failed for ‘https://blah/blah.git/’

git push origin master from command line works!

@joaomoreno

Thanks for the repo access. There was definitely a problem with VS Code’s credential helper. When running the push action, you should have seen this dialog:

image

The dialog is not showing up in 0.10.3 unfortunately. Fixed it and will be in for the December milestone.

With the fix, I was able to successfully push to the GitLab repo using the credentials I configured in the GitLab website.

@jasabalete

This dialog is showing to me. I put the credentials and show the error

@joaomoreno

I am using the username that I found in the bottom left corner of the GitLab UI. You can’t use your e-mail address.

image

And the password set in the following dialog:

image

Please make sure you are using the right credentials, reset your password, try again, etc.

@jasabalete

I know my credentials. I use this repository from several project with eclipse and command line too and works with ssh and https connections.

Thank for all :)

@joaomoreno

If you use the SSH remote url, it should all work, since no password prompt will occur.

If you use HTTPS, you should get the prompt. I do, I input the credentials I configured in GitLab and it works for me.

Maybe it’s platform specific? Which platform are you on?

@spongessuck

I have a development server on my domain that’s running Bonobo Git Server set up to use Windows authentication. My credentials work everywhere except in VS Code. I get a similar authentication error with the trailing slash.

@jasabalete

The new versión of VSCode WORKS :)

Thanks and go on!

@spongessuck

I’m using VSCode 0.10.6 (newest version) and I still have this problem.

@stefanvangastel

@spongessuck

@lv7777

I also arise same bug on windows8.

@user414

@joaomoreno

I support the cache credential helper as a workaround until we tackle this issue head on.

@BryanConradHart

I’m running into this problem too.
Ubuntu 15.10 (inside virtualbox on win10 pro)
VS Code -v 0.10.10

I do not get presented with a credential dialog.
I am able to successfully push from command line.
doing git config push.default matching, pushing from commandline and then trying again from vsCode made no difference.

@jonathanfishbein1

Similar set up to BryanConradHart getting the error

@jfaquinojr

@ansarizafar

I am also facing the same problem

@joaomoreno

The authentication dialog was fixed by #1796, it should start coming up on the next release.

Meanwhile, I do suggest using a credential helper.

@michaelazer

I’m running into the same error.
I can git push from the command line, but can’t through VS Code.
I get the following error:

Please make sure you have the correct access rights
and the repository exists.

I downloaded and installed the credential helper then tried both:
git config credential.helper cache
as well as
git config credential.helper store
but still doesn’t work.

ps. I’m using version 1.2.1

Thanks a lot for your support.

@jm-rives

I was having a similar problem with OSX. I turned OFF 2 — factor authentication and the problem resolved itself.

@Ron1137

I tried pushing to git hub but I got an error message saying couldn’t connect to server . What can I do?
I followed all the push instruction , disabled the wifi proxy settings and used LAN cable but still nothing

@larssb

@vscodebot
vscodebot
bot

locked and limited conversation to collaborators

Nov 17, 2017

Labels

bug

Issue identified by VS Code Team member as probable bug

verified

Verification succeeded

This article focuses on discussing how to solve git error (remote: Invalid username or password / fatal: Authentication failed). The approach will be to create a dummy example project file and upload it to the Git Repository properly without the following error.

Prerequisites: Git Repository, GitBash, Git Clone

Step By Step Solution

Step 1: Creating git repository and installing GitBash

You will first create a git repository where you will be pushing all your project files. And for that, you need to be installed with GitBash too (How to Install Gitbash and How to Work and Push Code on Git Repository?)

Once you are familiar with the above things, you can now move ahead with the article which will be focusing on the git error (remote: Invalid username or password / fatal: Authentication failed).

Step 2: For demonstration purposes, we have created a dummy git repository that looks something like the image attached below.

Creating dummy git repo

Creating dummy git repo 

Created successfully and prompted with quick setup

Created successfully and prompted with quick setup

Following image attached below shows the files which we are gonna upload to the GitHub repository.

DEMO FILES

DEMO FILES

Step 3: Checking whether GitBash has been installed on our machine successfully or not.

Checking GitBash

Checking GitBash

Step 4: Once Steps 2 and 3 is been done

If while doing step 2 i.e. following the quick setup tutorial or the article which is attached in step 1 on how git works, if you are prompted with the error (remote: Invalid username or password / fatal: Authentication failed) i.e. as shown in the image attached below. Then this article is gonna focus on that error only.

error

error

Step 5: Solve the error

A) Go to settings in your Github account >> Developer settings >> Personal access token >> Tokens (classic) >> Generate new token. See the images attached below for a better understanding.

A) 1

A) 2

A) 3

A) 4

For generating tokens you can follow up on this article (How to Create GitHub Personal Access Token).

B) Once you are ready with the token go again to your GitBash terminal and execute the push command. You will be redirected to a popup as shown in the image below:

POPUP

POPUP

C) Next, here in the pop-up tab you can:

  1. Simply copy and paste the token which you have generated just now.
  2. Or, you can go ahead and click on Sign in with your browser.

Once that is done you have finally reached your destination, you will be redirected to a new page saying, see the image below.

Succeded

Succeeded

Once this is done close the tab and go to GitBash again and you will see the error is been solved and all the files must be uploaded successfully.

UPLOADED successfully

UPLOADED Successfully

You can also visit the GitHub repository and see your files have been uploaded successfully without the error (remote: Invalid username or password / fatal: Authentication failed).

Verifying by visiting GitHub repo (UPLOADED successfully)

Verifying by visiting the GitHub repo (UPLOADED successfully)

In this way, you can add your Project files to the GitHub repository without the git error i.e. (remote: Invalid username or password / fatal: Authentication failed).

Last Updated :
07 Feb, 2023

Like Article

Save Article

Понравилась статья? Поделить с друзьями:
  • Farming simulator 22 ошибка драйвера видеокарты
  • Farming simulator 22 ошибка msvcp110
  • Farming simulator 22 ошибка 0xc000007b
  • Farming simulator 2019 ошибка при запуске приложения 0xc0000142
  • Farming simulator 2017 ошибка при запуске steam