You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Document where authentication credentials are stored #1773
Describe the feature or problem you’d like to solve
I can't find any information on the website or in the CLI help command about where authentication information is stored.
Proposed solution
Document where GH CLI stores authentication credentials. Also explain the relationship of this with existing GitHub credentials you may have on your system, like an SSH key or git https credentials in the keychain.
This helps the user understand the security and practical implications of logging in to the CLI.
$ gh auth status
github.com
✓ Logged in to github.com as mislav (~/.config/gh/hosts.yml)
✓ Git operations for github.com configured to use https protocol.
The authentication credentials are stored in ~/.config/gh/hosts.yml.
Good points about documentation; thank you!
Reacted by Nuru, Angelofdeath6911, Cameron Smith, Vincent G, R S, Dixon Sean Low Yan Feng, Chinarut, udance4ever, Marek, ttd and 1 more
@mislav Hi there, I was taking a look at this issue but I couldn't find where the documentation should be. I am guessing https://cli.github.com/manual/gh_auth_status here but even if that's the right place I don't see where or how the project is generating the documentation. If you could point me in the right direction I can help out with the change. Thanks 🙇
@cored Our documentation pages are autogenerated by spf13/cobra during our release workflow. As for where we actually want this documentation to be placed I think we should wait for @mislav to chime in on that.
@cored@eacp All the implementation for gh commands, such as gh auth status, is under pkg/cmd/; e.g. pkg/cmd/auth/status/status.go. You will find the documentation for the command there that is also used to generate the man page.
Please document clearly where sensitive information is stored, and whether or not it is stored in plain text form. For example, it appears .config/gh/hosts.yml contains sensitive authentication tokens that should be protected.
Reacted by seph, Gibson Fahnestock, Steve Ruble, Richard Bullington-McGuire, Zoltán Reegn, Kyle W. Rader, Isaac Joseph, Chris Stuart Parry, Marek, Markus Eicher and 2 more
Remember, users don't know a system when they're looking for answers. The actual answer can be stored in gh status, but it'd be really valuable to include a see also reference from gh config.
Related question: It is unclear to me if trying to configure SSH auth is going to wipe-out my existing ssh authentication for Git. I already have an ssh key generated, and uploaded to Github, but the gh auth login command seems to ignore that there's already a key there and still wants to log in via web browser.
Does this warrant a new issue specifically to allow using existing ssh configurations?
@kyle-radergh is trying to log in via a web browser in order to get an oauth token it can use to call the GitHub API; it's a different authentication than the SSH key used for git operations. If you answer "no" to gh setting up git auth for you and select ssh as your preferred git protocol, your existing SSH key will continue to work normally for git operations.
@jsoref, I think it would also make sense to put the information in gh auth login. Because this command is what is storing the credentials. I think it should also explain the config it is doing or point to gh auth setup-git. Because it would explain better how credentials are stored, because they are stored using a credential manager. And also (but this is more another issue) gh auth setup-git doesn't explain what it is setting up:
This command configures git to use GitHub CLI as a credential helper. For more information on git credential helpers please reference: https://git-scm.com/docs/gitcredentials.
I think it should explain what it is changing in .gitconfig. For example will it automatically configure your email and username with your github's account details? (see #4351 (comment)) I don't think so, but it doesn't explain it anywhere.
I wonder if there is an way to ask gh to report credentials (token) for a specific server. I am writing a python tool that uses github api to perform some tasks and re-using authentication from gh makes it easier for users instead of adding another place to store credentials.
So tokens are not stored as plain text in a config file, but running gh auth token will still display it?
Assuming e. g. some package manager's install script wants to collection system information, the keychain-based storage does not help, right? Or is the token being displayed a short-lived one?
Activity
mislav commentedon Sep 18, 2020
@raiskila Have you tried
gh auth status?The authentication credentials are stored in
~/.config/gh/hosts.yml.Good points about documentation; thank you!
raiskila commentedon Sep 18, 2020
Thanks for pointing that out, I was on 0.9.0 due to outdated Homebrew formulas and
gh auth statuswas missing.Yeah, this was mostly about the documentation, but I'm glad the information is also available there!
cored commentedon Oct 28, 2020
@mislav Hi there, I was taking a look at this issue but I couldn't find where the documentation should be. I am guessing https://cli.github.com/manual/gh_auth_status here but even if that's the right place I don't see where or how the project is generating the documentation. If you could point me in the right direction I can help out with the change. Thanks 🙇
samcoe commentedon Oct 29, 2020
@cored Our documentation pages are autogenerated by spf13/cobra during our release workflow. As for where we actually want this documentation to be placed I think we should wait for @mislav to chime in on that.
eacp commentedon Dec 10, 2020
Where would you like that directory to be?
mislav commentedon Dec 10, 2020
@cored @eacp All the implementation for
ghcommands, such asgh auth status, is underpkg/cmd/; e.g.pkg/cmd/auth/status/status.go. You will find the documentation for the command there that is also used to generate the man page.alexttx commentedon Sep 8, 2021
Please document clearly where sensitive information is stored, and whether or not it is stored in plain text form. For example, it appears
.config/gh/hosts.ymlcontains sensitive authentication tokens that should be protected.gibfahn commentedon Dec 27, 2021
For this bit specifically, see #449
jsoref commentedon Apr 1, 2022
Fwiw, I'd expect to be able to find the information by looking here: https://cli.github.com/manual/gh_config
Remember, users don't know a system when they're looking for answers. The actual answer can be stored in
gh status, but it'd be really valuable to include asee alsoreference fromgh config.kyle-rader commentedon Feb 26, 2023
Related question: It is unclear to me if trying to configure SSH auth is going to wipe-out my existing ssh authentication for Git. I already have an ssh key generated, and uploaded to Github, but the
gh auth logincommand seems to ignore that there's already a key there and still wants to log in via web browser.Does this warrant a new issue specifically to allow using existing ssh configurations?
vilmibm commentedon Mar 1, 2023
@kyle-rader
ghis trying to log in via a web browser in order to get an oauth token it can use to call the GitHub API; it's a different authentication than the SSH key used forgitoperations. If you answer "no" toghsetting upgitauth for you and selectsshas your preferredgitprotocol, your existing SSH key will continue to work normally forgitoperations.kyle-rader commentedon Mar 3, 2023
@vilmibm thanks for clarifying Nate, this makes sense. I take it github just doesn't support ssh auth for their web api? Only the git endpoints?
vilmibm commentedon Mar 3, 2023
@kyle-rader correct.
prggTheProgrammer commentedon Apr 24, 2023
@jsoref, I think it would also make sense to put the information in
gh auth login. Because this command is what is storing the credentials. I think it should also explain the config it is doing or point togh auth setup-git. Because it would explain better how credentials are stored, because they are stored using a credential manager. And also (but this is more another issue)gh auth setup-gitdoesn't explain what it is setting up:I think it should explain what it is changing in
.gitconfig. For example will it automatically configure your email and username with your github's account details? (see #4351 (comment)) I don't think so, but it doesn't explain it anywhere.ssbarnea commentedon Jan 12, 2024
I wonder if there is an way to ask gh to report credentials (token) for a specific server. I am writing a python tool that uses github api to perform some tasks and re-using authentication from gh makes it easier for users instead of adding another place to store credentials.
jsoref commentedon Jan 12, 2024
https://cli.github.com/manual/gh_auth_token
riywo commentedon Aug 21, 2024
I think
ghrespects several environment variables so that the exact location varies: https://cli.github.com/manual/gh_help_environmentSo, I guess mentioning the possibility of storing credentials inside the config dir on the document above would be helpful.
KJ7LNW commentedon May 28, 2025
where does
gh auth tokenget its token? none of these files contain the key:gibfahn commentedon May 31, 2025
Tokens are stored in the keychain as of #449
mpdude commentedon Sep 24, 2025
So tokens are not stored as plain text in a config file, but running
gh auth tokenwill still display it?Assuming e. g. some package manager's install script wants to collection system information, the keychain-based storage does not help, right? Or is the token being displayed a short-lived one?