GH-AUTH-LOGIN(1)
π
GH-AUTH-LOGIN(1) β the gh auth login glow-up
okay so bestie, you're reading the GitHub CLI manual page for gh auth login, and honestly? this one's a little rite of passage π it's how you get your whole machine β¨authenticatedβ¨ so let's get into it, i promise it's not scary.
πΈ NAME πΈ
gh-auth-login β log in to a GitHub account. that's it. that's the vibe. π
β¨ SYNOPSIS β¨
gh auth login [flags]
π¦ DESCRIPTION π¦
So the whole point is: authenticate with a GitHub host. π«Ά
The default hostname is github.com β very "we're going to the main character" of it β but you can override that whenever with the --hostname flag.
The default authentication mode is a web-based browser flow. Once you finish it, an authentication token gets stored securely in the system credential store. π But β and this is the important bit β if a credential store is not found, or there's an issue using it, gh will fall back to writing the token to a plain text file. Yeah. Plain text. Not the slayest. See gh auth status for where it's actually stored.
Alternatively, use --with-token to pass in a personal access token (classic) on standard input. The minimum required scopes for the token are: repo, read:org, and gist. β And listen β take care when passing a fine-grained personal access token to --with-token, because the inherent scoping to certain resources may cause confusing behaviour when you're interacting with other resources. Favour setting GH_TOKEN for fine-grained personal access token usage instead. iykyk π
Alternatively alternatively, gh will use the authentication token found in environment variables. This method is the most suitable for "headless" use of gh, like in automation. See gh help environment for more info.
To use gh in GitHub Actions, add GH_TOKEN: ${{ github.token }} to env.
The git protocol used for git operations on this host can be set with --git-protocol, or during the interactive prompting. And here's a lil caveat π β although login is for a single account on a host, setting the git protocol will take effect for all users on the host. so like, everyone. bestie it's giving shared apartment energy.
Specifying ssh for the git protocol will detect existing SSH keys to upload, prompting to create and upload a new key if one isn't found. You can skip that whole prompt with the --skip-ssh-key flag. π§
For more information on OAuth scopes, see β¨https://docs.github.com/en/developers/apps/building-oauth-apps/scopes-for-oauth-apps/β©.
π₯ OPTIONS π₯
-c,--clipboardβ copy that one-time OAuth device code straight to your clipboard π-p,--git-protocol <string>β the protocol to use for git operations on this host:{ssh|https}-h,--hostname <string>β the hostname of the GitHub instance you're authenticating with--insecure-storageβ save authentication credentials in plain text instead of the credential store (yes, this is the unserious option, choose wisely)-s,--scopes <strings>β additional authentication scopes to request--skip-ssh-keyβ skip the generate/upload SSH key prompt-w,--webβ open a browser to authenticate--with-tokenβ read token from standard input
π EXIT CODES π
0β successful execution β¨1β error π2β command canceled4β authentication required π
NOTE: specific commands may have additional exit codes. refer to the command's help for more information. don't come for me, i'm just the messenger π
π EXAMPLE π
# Start interactive setup
$ gh auth login
# Open a browser to authenticate and copy one-time OAuth code to clipboard
$ gh auth login --web --clipboard
# Authenticate against github.com by reading the token from a file
$ gh auth login --with-token < mytoken.txt
# Authenticate with specific host
$ gh auth login --hostname enterprise.internal
π SEE ALSO π
gh-auth(1) β go read that one too, it's the parent lore π«Ά
<div align="center">π that's the page, bestie! brought to you by GitHub CLI v2.102.0, dated Oct 2026 β go forth and authenticate, you gorgeous icon πΈβ¨</div>
π¦ where this page comes from
- opensuse-leap 16.0: gh 2.102.0-bp160.1.1 Β· MIT
- opensuse-leap 16.0: gh 2.102.0-bp160.1.1 Β· MIT
- opensuse-leap 16.0: gh 2.102.0-bp160.1.1 Β· MIT
- opensuse-leap 16.0: gh 2.102.0-bp160.1.1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms