1.7 KiB
1.7 KiB
title |
---|
GitHub 2FA |
Prepare your phone
Install Google Authenticator. Works for iOS and Android.
Enable 2FA
- Enable 2 factor authentication on the GitHub website (Settings → Security → Two Factor Authentication).
- Take a picture of the QR code using Google Authenticator.
Enable password caching
On your computer, enable caching your GitHub HTTPS credentials.
git config --global credential.helper osxkeychain # OSX
git config --global credential.helper cache # Linux
Use HTTPS on your repos
If your git repos still use SSH (git@github.com:user/repo.git
), change them to use HTTPS (https://github.com/user/repo.git
). Info here.
cd project
vim .git/config
Generate an API key
- Generate an API key under "Personal Access Tokens".
- Leave the scopes unchanged (as long as there's repo + public_repo)
Git push
Push a repo. You'll be asked for a password. Use the token for the password.
$ git push
Username for 'https://github.com': rstacruz
Password for 'https://rstacruz@github.com':
That's it!
Further reading:
- Providing your 2FA Authentication Code (github.com)
- Caching your GitHub password (github.com)
- HTTPS remote URLs (github.com)