Reading list Switch to dark mode

    Make “git pull/push/clone” work with two factor authentication

    Updated 16 July 2021

    Today I face an issue when I was trying to push my recent changes on my GITHUB directory.  I was getting an access authentication error even my details were correct.

    Authentication Error
    Authentication Error

    Then a bit searching a got to know that I am getting this error because of 2FA(two-factor authentication) is enabled in my account which I enabled a few days ago.

    Basically, 2FA provides an extra layer of security used when logging into the account. For more details please refer to the GITHUB TWO FACTOR AUTHENTICATION

    2FA requires user access token instead of the user password while running pull and push operation in GITHUB.

    • Without 2FA
      • $ git clone https://github.com/ashish-webkul/webkul-repo.git
        • Username: your_username
        • Password: your_password
    • With 2FA
      • $ git clone https://github.com/ashish-webkul/webkul-repo.git
        • Username: your_username
        • Password: your_access_token

    Then first we need to know how to set up access token key on GITHUB account for the command line. Steps are given below,

    Searching for an experienced
    Akeneo Company ?
    Read More
    • First of all, make sure your email-id should be verified. If not then verify first.
    • Then go to the top right corner of your GITHUB account. Where you will see your profile picture. Click on that picture and then click on setting.
    GITHUB Main Settings
    GITHUB Main Settings

    Then on the left side menubar, you will see Developer Setting“. Click on it and then click on “Personal access tokens”

    Developer Setting
    Developer Setting
    Personal Access Token
    Personal Access Token

    Then you will see a button “Generate new token“. Click on that button to generate an access token,

    Token Menu
    Token Menu

    Then after giving the access token name select the permission which you would like to give for that token.

    GITHUB Token Name
    GITHUB Token Name
    Permissions
    Select permissions for access tokens

    After that click on “Generate Token“. Then you token will appear on the window.

    GITHUB Account Token
    GITHUB Account Token

    This is how you can create an access token.

    NOTE: Keep your access token secret 

    Now you can use access token as your authentication password for GITHUB pull & push operations.

    We would love the hear your thoughts, suggestions, and questions in the comments below !!

    . . .
    Discuss on Helpdesk

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    28 comments

  • Danny
    Perfect work instructions, thank you.
    • Neelesh Singh (Moderator)
      Hello There,

      Thank you very much for your appreciation. For any suggestions, you can also email us at [email protected] and we will get back to you accordingly.

      Regards
      Webkul Team

  • csi cs
    Not working bro
    • Ashish Singh (Moderator)
      Hi, 
      Could you please share the screenshot where you are getting the error then it will be helpful for us to check your query and share the solution.
       
      Thanks & Regards,
      Ashish Singh
  • Abduttayyeb
    Thanks, this saved a lot of time..!
    • Anisha Bahukhandi (Moderator)

      Hello Abuttayyeb,
      Thanks for your valuable feedback! Stay tuned for more posts…
      Regards
      Anisha Bahukhandi

  • Chris
    Thanks for your explanation, it helped a lot!
    • Anisha Bahukhandi (Moderator)
      Hello chris,
      Thanks for your valuable feedback! Stay tuned for more posts…
      Regards
      Anisha Bahukhandi
  • Juan Ramos
    Unfortunately it doesn’t work. I used my token instead of password but continue getting the same error message.
    • Ashish Singh (Moderator)
      Hi, Juan
      In case you are still getting the same issue then there must be some permission issue while creating your token.
      https://cdnblog.webkul.com/blog/wp-content/uploads/2019/05/Screenshot-6.png 
      So kindly try to regenerate your token with proper/full permission.
      Then recheck by doing git operations.
      Feel free to ask in case you will get the same issue.
       
      Thanks & Regards,
      Ashish Singh
       
  • sravan
    Awsome, its really helpful to me and resolve my issue. Once again Thanks a lot 🙂
    • Ashish Singh (Moderator)
      Hello Sravan,

      Thanks for your valuable feedback and appreciation.
      Stay tuned for more informational blogs.

      Regards
      Ashish Singh

  • F
    Why don’t use SSH instead?!
  • Albert Hidalgo
    Thanks so much!
    • Ashish Singh
      Hello Albert,

      Thanks for your valuable feedback and appreciation.
      Stay tuned for more informational blogs.

      Regards
      Ashish Singh

  • M.
    Very good to know. To be honest I had turned off 2FA for my account because I didn’t know about this workaround until now. Thank you!
    • Ashish Singh (Moderator)
      Hello Charles,

      Thanks for your valuable feedback and appreciation.
      Stay tuned for more informational blogs.

      Regards
      Ashish Singh

  • Naotho
    Thank you!
    • Anisha Bahukhandi (Moderator)
      Hello Naotho,
      Thanks for your valuable feedback!
      Stay tuned for more informational blogs…

      Regards
      Anisha Bahukhandi

  • Arun
    How to clone a git repository from commandline with PersonalAccessToken?
  • Iain Sanderson
    Superb!!!
    I finally found this blog and fix my issue.
    Thank you.
    • Megha Joshi (Moderator)
      Hello Iain,
      Thanks for the feedback, for any further assistance kindly drop us a mail at- [email protected]

      Regards,
      Megha

  • [email protected]
    Excellent. Works perfectly fine. Thank you.
    • Megha Joshi (Moderator)
      Hello,
      Thank you for the feedback.

      Regards,
      Megha
      Webkul

  • Lucas Andrade
    Awesome tutorial, thank you so much. The pictures really helped me.
    • Megha Joshi (Moderator)
      Hello Lucas,
      Thanks for your valuable feedback and appreciation.

      Regards,
      Megha
      Webkul

  • Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home