docs icon indicating copy to clipboard operation
docs copied to clipboard

docs: add a new ssh key using GitHub cli

Open schalkneethling opened this issue 2 years ago • 2 comments
trafficstars

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 avatar Jun 12 '23 20:06 schalkneethling

👋 @schalkneethling Good to see you again! Thanks for opening an issue. I'll get this triaged for review ⚡

cmwilson21 avatar Jun 13 '23 13:06 cmwilson21

Thanks for opening an issue! We've triaged this issue for technical review by a subject matter expert :eyes:

github-actions[bot] avatar Jun 26 '23 14:06 github-actions[bot]

This is a gentle bump for the docs team that this issue is waiting for technical review.

github-actions[bot] avatar Jul 24 '23 16:07 github-actions[bot]

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 🙂

isaacmbrown avatar Aug 17 '23 10:08 isaacmbrown

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!

electron97 avatar Aug 18 '23 18:08 electron97