GitHub CLI | Take GitHub to the command line
https://cli.github.com/manual/gh_auth_login • 102 KB fetched Open original page
GitHub CLI | Take GitHub to the command line
Skip to content
CLI
Copilot CLI
Manual
Release notes
*
Getting started
*
gh
*
agent-task
*
create
*
list
*
view
*
alias
*
delete
*
import
*
list
*
set
*
api
*
attestation
*
download
*
trusted-root
*
verify
*
auth
*
login
*
logout
*
refresh
*
setup-git
*
status
*
switch
*
token
*
browse
*
cache
*
delete
*
list
*
codespace
*
code
*
cp
*
create
*
delete
*
edit
*
jupyter
*
list
*
logs
*
ports
*
ports forward
*
ports visibility
*
rebuild
*
ssh
*
stop
*
view
*
completion
*
config
*
clear-cache
*
get
*
list
*
set
*
copilot
*
discussion
*
comment
*
create
*
edit
*
list
*
view
*
extension
*
browse
*
create
*
exec
*
install
*
list
*
remove
*
search
*
upgrade
*
gist
*
clone
*
create
*
delete
*
edit
*
list
*
rename
*
view
*
gpg-key
*
add
*
delete
*
list
*
help
*
environment
*
exit-codes
*
formatting
*
mintty
*
reference
*
telemetry
*
issue
*
close
*
comment
*
create
*
delete
*
develop
*
edit
*
list
*
lock
*
pin
*
reopen
*
status
*
transfer
*
unlock
*
unpin
*
view
*
label
*
clone
*
create
*
delete
*
edit
*
list
*
licenses
*
org
*
list
*
pr
*
checkout
*
checks
*
close
*
comment
*
create
*
diff
*
edit
*
list
*
lock
*
merge
*
ready
*
reopen
*
revert
*
review
*
status
*
unlock
*
update-branch
*
view
*
preview
*
prompter
*
project
*
close
*
copy
*
create
*
delete
*
edit
*
field-create
*
field-delete
*
field-list
*
item-add
*
item-archive
*
item-create
*
item-delete
*
item-edit
*
item-list
*
link
*
list
*
mark-template
*
unlink
*
view
*
release
*
create
*
delete-asset
*
delete
*
download
*
edit
*
list
*
upload
*
verify-asset
*
verify
*
view
*
repo
*
archive
*
autolink
*
autolink create
*
autolink delete
*
autolink list
*
autolink view
*
clone
*
create
*
delete
*
deploy-key
*
deploy-key add
*
deploy-key delete
*
deploy-key list
*
edit
*
fork
*
gitignore
*
gitignore list
*
gitignore view
*
license
*
license list
*
license view
*
list
*
read-dir
*
read-file
*
rename
*
set-default
*
sync
*
unarchive
*
view
*
ruleset
*
check
*
list
*
view
*
run
*
cancel
*
delete
*
download
*
list
*
rerun
*
view
*
watch
*
search
*
code
*
commits
*
issues
*
prs
*
repos
*
secret
*
delete
*
list
*
set
*
skill
*
install
*
list
*
preview
*
publish
*
search
*
update
*
ssh-key
*
add
*
delete
*
list
*
status
*
variable
*
delete
*
get
*
list
*
set
*
workflow
*
disable
*
enable
*
list
*
run
*
view
CLI manual
*
Getting started
*
gh
*
agent-task
*
create
*
list
*
view
*
alias
*
delete
*
import
*
list
*
set
*
api
*
attestation
*
download
*
trusted-root
*
verify
*
auth
*
login
*
logout
*
refresh
*
setup-git
*
status
*
switch
*
token
*
browse
*
cache
*
delete
*
list
*
codespace
*
code
*
cp
*
create
*
delete
*
edit
*
jupyter
*
list
*
logs
*
ports
*
ports forward
*
ports visibility
*
rebuild
*
ssh
*
stop
*
view
*
completion
*
config
*
clear-cache
*
get
*
list
*
set
*
copilot
*
discussion
*
comment
*
create
*
edit
*
list
*
view
*
extension
*
browse
*
create
*
exec
*
install
*
list
*
remove
*
search
*
upgrade
*
gist
*
clone
*
create
*
delete
*
edit
*
list
*
rename
*
view
*
gpg-key
*
add
*
delete
*
list
*
help
*
environment
*
exit-codes
*
formatting
*
mintty
*
reference
*
telemetry
*
issue
*
close
*
comment
*
create
*
delete
*
develop
*
edit
*
list
*
lock
*
pin
*
reopen
*
status
*
transfer
*
unlock
*
unpin
*
view
*
label
*
clone
*
create
*
delete
*
edit
*
list
*
licenses
*
org
*
list
*
pr
*
checkout
*
checks
*
close
*
comment
*
create
*
diff
*
edit
*
list
*
lock
*
merge
*
ready
*
reopen
*
revert
*
review
*
status
*
unlock
*
update-branch
*
view
*
preview
*
prompter
*
project
*
close
*
copy
*
create
*
delete
*
edit
*
field-create
*
field-delete
*
field-list
*
item-add
*
item-archive
*
item-create
*
item-delete
*
item-edit
*
item-list
*
link
*
list
*
mark-template
*
unlink
*
view
*
release
*
create
*
delete-asset
*
delete
*
download
*
edit
*
list
*
upload
*
verify-asset
*
verify
*
view
*
repo
*
archive
*
autolink
*
autolink create
*
autolink delete
*
autolink list
*
autolink view
*
clone
*
create
*
delete
*
deploy-key
*
deploy-key add
*
deploy-key delete
*
deploy-key list
*
edit
*
fork
*
gitignore
*
gitignore list
*
gitignore view
*
license
*
license list
*
license view
*
list
*
read-dir
*
read-file
*
rename
*
set-default
*
sync
*
unarchive
*
view
*
ruleset
*
check
*
list
*
view
*
run
*
cancel
*
delete
*
download
*
list
*
rerun
*
view
*
watch
*
search
*
code
*
commits
*
issues
*
prs
*
repos
*
secret
*
delete
*
list
*
set
*
skill
*
install
*
list
*
preview
*
publish
*
search
*
update
*
ssh-key
*
add
*
delete
*
list
*
status
*
variable
*
delete
*
get
*
list
*
set
*
workflow
*
disable
*
enable
*
list
*
run
*
view
gh auth login
gh auth login [flags]
Authenticate with a GitHub host.
The default hostname is github.com . This can be overridden using the --hostname
flag.
The default authentication mode is a web-based browser flow. After completion, an
authentication token will be stored securely in the system credential store.
If a credential store is not found or there is an issue using it gh will fallback
to writing the token to a plain text file. See gh auth status for its
stored location.
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 .
Take care when passing a fine-grained personal access token to --with-token
as the inherent scoping to certain resources may cause confusing behaviour when interacting with other
resources. Favour setting GH_TOKEN for fine-grained personal access token usage.
Alternatively, gh will use the authentication token found in environment variables.
This method is most suitable for "headless" use of gh such as 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 to use for git operations on this host can be set with --git-protocol ,
or during the interactive prompting. Although login is for a single account on a host, setting
the git protocol will take effect for all users on the host.
Specifying ssh for the git protocol will detect existing SSH keys to upload,
prompting to create and upload a new key if one is not found. This can be skipped with
--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 one-time OAuth device code to 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 to authenticate with
--insecure-storage
Save authentication credentials in plain text instead of credential store
-s ,
--scopes <strings>
Additional authentication scopes to request
--skip-ssh-key
Skip generate/upload SSH key prompt
-w ,
--web
Open a browser to authenticate
--with-token
Read token from standard input
Examples
# 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
Product
* Features
* Security
*
Enterprise
*
Customer stories
* Pricing
*
Resources
Platform
*
Developer API
* Partners
*
GitHub Desktop
*
GitHub Mobile
Support
* Help
*
Community Forum
*
Expert Services
* Status
*
Contact GitHub
Company
* About
* Blog
*
Careers
* Press
* Shop
* (c) 2026 GitHub, Inc.
*
Terms
*
Privacy
*
Telemetry
*
*
*
*
*
Links found on this page
- Skip to content [direct]
- CLI [direct]
- Copilot CLI [direct]
- Manual [direct]
- Release notes [direct]
- Getting started [direct]
- gh [direct]
- agent-task [direct]
- create [direct]
- list [direct]
- view [direct]
- alias [direct]
- delete [direct]
- import [direct]
- list [direct]
- set [direct]
- api [direct]
- attestation [direct]
- download [direct]
- trusted-root [direct]
- verify [direct]
- auth [direct]
- logout [direct]
- refresh [direct]
- setup-git [direct]
- status [direct]
- switch [direct]
- token [direct]
- browse [direct]
- cache [direct]
- delete [direct]
- list [direct]
- codespace [direct]
- code [direct]
- cp [direct]
- create [direct]
- delete [direct]
- edit [direct]
- jupyter [direct]
- list [direct]
- logs [direct]
- ports [direct]
- ports forward [direct]
- ports visibility [direct]
- rebuild [direct]
- ssh [direct]
- stop [direct]
- view [direct]
- completion [direct]
- config [direct]
- clear-cache [direct]
- get [direct]
- list [direct]
- set [direct]
- copilot [direct]
- discussion [direct]
- comment [direct]
- create [direct]
- edit [direct]
- list [direct]
- view [direct]
- extension [direct]
- browse [direct]
- create [direct]
- exec [direct]
- install [direct]
- list [direct]
- remove [direct]
- search [direct]
- upgrade [direct]
- gist [direct]
- clone [direct]
- create [direct]
- delete [direct]
- edit [direct]
- list [direct]
- rename [direct]
- view [direct]
- gpg-key [direct]
- add [direct]
|
|