Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

2FA give problems when pushing to GitHub

I've clone a project on GitHub on my Raspberry Pi, create a new branch and push everything to the repository. For this I needed next commands:

git clone https://www.github.com/heinpauwelyn/my_repo git checkout -b raspberry git push origin raspberry 

The problem I've got is that I can't push the branch to GitHub.com. I need to enter my username and password, but I can't use 2FA for that. Is this a bug in Git or GitHub and is there a way to get an authentication key and enter it?

I'll not enable the 2FA on GitHub.

like image 542
H. Pauwelyn Avatar asked Dec 03 '16 17:12

H. Pauwelyn


People also ask

Why I Cannot push to GitHub authentication failed?

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.

Does GitHub require 2 factor authentication?

Before you can require organization members, outside collaborators, and billing managers to use two-factor authentication, you must enable two-factor authentication for your account on GitHub.


2 Answers

with 2FA you have to create a personal access token to use as a password when authenticating to GitHub on the command line with HTTPS URLs: https://help.github.com/articles/which-remote-url-should-i-use/#when-2fa-is-enabled

or you can clone with ssh https://help.github.com/articles/which-remote-url-should-i-use/#cloning-with-ssh-urls (may also be useful: https://help.github.com/articles/generating-an-ssh-key/)

like image 137
pedrorijo91 Avatar answered Oct 10 '22 22:10

pedrorijo91


You have to generate an access token and use the access token instead the password. For example:

$ git clone https://github.com/username/repo.git Username: your_username Password: your_token 

Doc: https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line

like image 31
Carlos Giovani Barillas Colón Avatar answered Oct 10 '22 23:10

Carlos Giovani Barillas Colón