Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document where authentication credentials are stored #1773

Open
raiskila opened this issue Sep 18, 2020 · 17 comments
Open

Document where authentication credentials are stored #1773

raiskila opened this issue Sep 18, 2020 · 17 comments
Labels
docs enhancement a request to improve CLI gh-auth relating to the gh auth command help wanted Contributions welcome

Comments

@raiskila
Copy link

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.

@raiskila raiskila added the enhancement a request to improve CLI label Sep 18, 2020
@mislav
Copy link
Contributor

mislav commented Sep 18, 2020

@raiskila Have you tried gh auth status?

$ 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!

@mislav mislav added the docs label Sep 18, 2020
@raiskila
Copy link
Author

Thanks for pointing that out, I was on 0.9.0 due to outdated Homebrew formulas and gh auth status was missing.

Yeah, this was mostly about the documentation, but I'm glad the information is also available there!

@vilmibm vilmibm added the help wanted Contributions welcome label Oct 22, 2020
@cored
Copy link

cored commented 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
Copy link
Contributor

samcoe commented 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.

@mislav mislav mentioned this issue Nov 24, 2020
8 tasks
@eacp
Copy link

eacp commented Dec 10, 2020

Where would you like that directory to be?

@mislav
Copy link
Contributor

mislav commented Dec 10, 2020

@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.

@alexttx
Copy link

alexttx commented 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.yml contains sensitive authentication tokens that should be protected.

@gibfahn
Copy link

gibfahn commented Dec 27, 2021

For example, it appears .config/gh/hosts.yml contains sensitive authentication tokens that should be protected.

For this bit specifically, see #449

@jsoref
Copy link
Contributor

jsoref commented 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 a see also reference from gh config.

@kyle-rader
Copy link

kyle-rader commented 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 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?

@vilmibm
Copy link
Contributor

vilmibm commented Mar 1, 2023

@kyle-rader gh 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.

@kyle-rader
Copy link

@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
Copy link
Contributor

vilmibm commented Mar 3, 2023

@kyle-rader correct.

@prggTheProgrammer
Copy link

Fwiw, I'd expect to be able to find the information by looking here: https://cli.github.com/manual/gh_config

@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.

@samcoe samcoe added the gh-auth relating to the gh auth command label Oct 2, 2023
@ssbarnea
Copy link

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
Copy link
Contributor

jsoref commented Jan 12, 2024

https://cli.github.com/manual/gh_auth_token

@riywo
Copy link

riywo commented Aug 21, 2024

I think gh respects several environment variables so that the exact location varies: https://cli.github.com/manual/gh_help_environment

So, I guess mentioning the possibility of storing credentials inside the config dir on the document above would be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs enhancement a request to improve CLI gh-auth relating to the gh auth command help wanted Contributions welcome
Projects
None yet
Development

No branches or pull requests