Wednesday, December 17, 2014

Github - Two-Factor Authentication and HTTPS pull and push

Once you enabled "Two-Factor" authentication in your Github account, you can't push or pull to any of your repositories anymore through HTTPS. You need to create a "Personal Access Token" to be able to push over HTTPS again.

Setting up "Personal Access Token":
1. Log into your Github account.
2. Go into "Account Settings".
3. Go to "Applications" -> "Personal access tokens".
4. Generate your own token.

Save your token into some encrypted file.

To test your token:
$ curl -u your_token_without_square_bracket:x-oauth-basic

You should see something like:
  "login": "xxxx",
  "id": 234233,
  "avatar_url": "",
  "gravatar_id": "",
  "url": "",
  "html_url": "",
  "followers_url": "",
  "following_url": "{/other_user}",

To let git command pick it up automatically:
Add the following into your ~/.netrc file:
login username
password <your_token>
protocol https

Now you can push and pull, happy coding!

1 comment:

az said...