Every time I get a new machine, I used to configure SSH keys for GitHub to clone and push code. But I never bothered to keep track of the keys, so I ended up recreating them repeatedly. It wasn’t until I ran into multica and browsed the issue tracker that I realized GitHub provides GitHub CLI (gh) for quick authentication…
Installation Methods
Method 1: Install via apt (Recommended)
Debian 13 and newer versions of Ubuntu have included gh in their official repositories, so you can install it directly:
1 | sudo apt update |
Authentication
After installation, the first step is to log into your GitHub account:
1 | gh auth login |
This starts an interactive flow:
- Choose GitHub.com as the account type
- Choose HTTPS as the protocol
- Choose Login with a web browser and copy the one-time code displayed
- Paste the code in your browser and authorize
- The terminal will confirm successful authentication
For non-interactive authentication using a Token:
1 | gh auth login --with-token < my_token.txt |
How Git Benefits from gh Authentication
After gh auth login, git automatically uses gh‘s credential manager:
git push,git pull, and other operations no longer ask for username/password for HTTPS remotes- No need to manually configure SSH keys for code operations
- All authentication is centrally managed through
gh