Search code examples
gitauthenticationgithubssh-keys

How to checkout a private github repository via HTTPS when 2-factor authentication is on?


At work and on my own computer I normally use github with ssh keys. I also installed 2-factor authentification via text-message. Everything works fine.

But when I'm at another computer, where I do not have my ssh key, I'm of course not able to checkout from my (private) repository via the

git clone git@github.com:joergi/myproject.git

But when I switch to the HTTPS Version I can not checkout via

git clone https://github.com/joergi/myproject.git
Cloning into 'myproject'...
Username for 'https://github.com': joergi
Password for 'https://joergi@github.com': 
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/joergi/myproject.git/'

Username and password are 100% correct.

Is there any way to use HTTPS , when 2-factor authentication is activated?


Solution

  • Here is documentation from github on how two factor auth behaves. It discusses https repositories on the command line. You can generate a personal access token and use that to login.

    The price of security is a inconvenience. You could temporarily disable two factor auth as well.