gh auth login Sign in the GitHub CLI to your account
Logs the gh command-line tool in to GitHub, usually through your browser, and stores a token so later gh commands and git over https can act as you.
Synopsis
gh auth login [FLAGS]
gh auth status
gh auth logout
Common options
| Option or form | What it does |
|---|---|
-h, --hostname HOST | Sign in to a specific host, such as a GitHub Enterprise server |
-w, --web | Open a browser to finish signing in |
-p, --git-protocol https|ssh | Which protocol git should use for your repositories |
-s, --scopes SCOPES | Ask for extra permissions on the token |
--with-token | Read a token from standard input instead of using the browser |
Examples
gh auth login
gh auth login --web --git-protocol https
gh auth status
github.com
✓ Logged in to github.com account octocat
gh auth login --with-token < token.txt
gh auth setup-git
Notes
- Never type a token on the command line. Pipe it in with --with-token so it does not land in your shell history.
- In automation, the GH_TOKEN environment variable works without running login at all.
- gh auth logout removes the stored token for that host.
See also
Last reviewed 2026-10-09.