SOLFIND
Web Lens
Portal home

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

  1. Skip to content [direct]
  2. CLI [direct]
  3. Copilot CLI [direct]
  4. Manual [direct]
  5. Release notes [direct]
  6. Getting started [direct]
  7. gh [direct]
  8. agent-task [direct]
  9. create [direct]
  10. list [direct]
  11. view [direct]
  12. alias [direct]
  13. delete [direct]
  14. import [direct]
  15. list [direct]
  16. set [direct]
  17. api [direct]
  18. attestation [direct]
  19. download [direct]
  20. trusted-root [direct]
  21. verify [direct]
  22. auth [direct]
  23. logout [direct]
  24. refresh [direct]
  25. setup-git [direct]
  26. status [direct]
  27. switch [direct]
  28. token [direct]
  29. browse [direct]
  30. cache [direct]
  31. delete [direct]
  32. list [direct]
  33. codespace [direct]
  34. code [direct]
  35. cp [direct]
  36. create [direct]
  37. delete [direct]
  38. edit [direct]
  39. jupyter [direct]
  40. list [direct]
  41. logs [direct]
  42. ports [direct]
  43. ports forward [direct]
  44. ports visibility [direct]
  45. rebuild [direct]
  46. ssh [direct]
  47. stop [direct]
  48. view [direct]
  49. completion [direct]
  50. config [direct]
  51. clear-cache [direct]
  52. get [direct]
  53. list [direct]
  54. set [direct]
  55. copilot [direct]
  56. discussion [direct]
  57. comment [direct]
  58. create [direct]
  59. edit [direct]
  60. list [direct]
  61. view [direct]
  62. extension [direct]
  63. browse [direct]
  64. create [direct]
  65. exec [direct]
  66. install [direct]
  67. list [direct]
  68. remove [direct]
  69. search [direct]
  70. upgrade [direct]
  71. gist [direct]
  72. clone [direct]
  73. create [direct]
  74. delete [direct]
  75. edit [direct]
  76. list [direct]
  77. rename [direct]
  78. view [direct]
  79. gpg-key [direct]
  80. add [direct]