Git Clone from GitHub over https with two-factor authentication

后端 未结 6 1747
感动是毒
感动是毒 2021-01-29 23:49

I recently began using two-factor authentication on GitHub, and I am now unable to use git over https on private repos in the usual way:

peter@computer:~$ git cl         


        
相关标签:
6条回答
  • 2021-01-30 00:13

    To everyone struggling, what worked for me was creating personal access token and then using it as a username AND password (in the prompt that opened).

    0 讨论(0)
  • 2021-01-30 00:15

    Find out how to fix this here:

    https://github.com/blog/1614-two-factor-authentication#how-does-it-work-for-command-line-git

    How does it work for command-line Git?

    If you are using SSH for Git authentication, rest easy: you don't need to do anything. If you are using HTTPS Git, instead of entering your password, enter a personal access token. These can be created by going to your personal access tokens page.

    0 讨论(0)
  • 2021-01-30 00:23

    As per @Nitsew's answer, Create your personal access token and use your token as your username and enter with blank password.

    Later you won't need any credentials to access all your private repo(s).

    0 讨论(0)
  • 2021-01-30 00:30

    It generally comes to mind that you have set up two-factor authentication, after a few password trials and maybe a password reset. So, how can we git clone a private repository using two-factor authentication? It is simple, using access tokens.

    How to Authenticate Git using Access Tokens

    1. Go to https://github.com/settings/tokens
    2. Click Generate New Token button on top right.
    3. Give your token a descriptive name.
    4. Set all required permissions for the token.
    5. Click Generate token button at the bottom.
    6. Copy the generated token to a safe place.
    7. Use this token instead of password when you use git clone.

    Wow, it works!

    0 讨论(0)
  • 2021-01-30 00:33

    1st: Get personal access token. https://github.com/settings/tokens
    2nd: Put account & the token. Example is here:

    $ git push
    Username for 'https://github.com':            # Put your GitHub account name
    Password for 'https://{USERNAME}@github.com': # Put your Personal access token
    

    Link on how to create a personal access token: https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line

    0 讨论(0)
  • 2021-01-30 00:38

    If your repo have 2FA enabled. Highly suggest to use the app provided by github.com Here is the link: https://desktop.github.com/

    After you downloaded it and installed it. Follow the withard, the app will ask you to provide the one time password for login. Once you filled in the one time password, you could see your repo/projects now.

    0 讨论(0)
提交回复
热议问题