docs
docs copied to clipboard
docs: add a new ssh key using GitHub cli
Code of Conduct
- [X] I have read and agree to the GitHub Docs project's Code of Conduct
What article on docs.github.com is affected?
https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account?tool=cli
What part(s) of the article would you like to see updated?
https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account?tool=cli#adding-a-new-ssh-key-to-your-account
The steps mentions to first authenticate with the GitHub CLI. I did this in the current terminal session so, I moved onto the next step. Specifically, gh ssh-key add ~/.ssh/id_ed25519.pub --title "memorable title". After pressing enter, I got the following:
HTTP 404: Not Found (https://api.github.com/user/keys?per_page=100)
This API operation needs the "admin:public_key" scope. To request it, run: gh auth refresh -h github.com -s admin:public_key
I assume when I first authenticated (I just ran gh auth login. Not in any specific context) I did not request these additional rights. I ran the auth refresh command which took me through the original flow (I authenticated through a web browser). Once I completed the authentication flow and reran ssh-key add, all is good and the key is added to my profile on GitHub.
May be a small thing, but it might catch some folks off guard.
Additional information
No response
👋 @schalkneethling Good to see you again! Thanks for opening an issue. I'll get this triaged for review ⚡
Thanks for opening an issue! We've triaged this issue for technical review by a subject matter expert :eyes:
This is a gentle bump for the docs team that this issue is waiting for technical review.
Hi @schalkneethling, thanks for creating the issue! gh auth login doesn't request all scopes right away so it's normal that you need to request additional scopes as you run different commands. This isn't always something we reflect in our docs
I think we could add a line like If you're prompted to request additional scopes, follow the instructions in the command line. before the command. Let us know if you'd be up for opening a PR to do that! I'll add the help wanted label so you or anyone else can do that 🙂
Hi @isaacmbrown ,
I have raised a PR: https://github.com/github/docs/pull/27571 based on your suggestion above. Could you pleased take a look whenever you get a chance?
Thanks!