1

I have two ssh keys i've created, first one for my personal use and the second one which I just created for work/school.

When I log into using git CLI using SSH with the second SSH key, it says that i have successfully logged in like below

$ winpty gh auth login
? What account do you want to log into? GitHub.com
? You're already logged into github.com. Do you want to re-authenticate? Yes
? What is your preferred protocol for Git operations? SSH
? Upload your SSH public key to your GitHub account? C:\Users\dykim\.ssh\id_rsa.
pub
? Title for your SSH key: (GitHub CLI) second-key

? Title for your SSH key: future_proof
? How would you like to authenticate GitHub CLI? Login with a web browser

! First copy your one-time code: 0B1D-6370
Press Enter to open github.com in your browser...
✓ Authentication complete.
- gh config set -h github.com git_protocol ssh
✓ Configured git protocol
HTTP 422: Validation Failed (https://api.github.com/user/keys)
key is already in use

so somehow there isn't a problem to authenticating. But I am worried that this will somehow pop up later and be a problem later when I am working on my future projects for work.

What can I do to avoid this issue?

torek
  • 448,244
  • 59
  • 642
  • 775
masafood
  • 325
  • 2
  • 11

1 Answers1

0

That seems similar to a pending reported issue #5299: "Spurious auth error when SSH key is already registered on account"

Steps to reproduce the behavior

  • Run gh auth login and select an SSH key that is already registered with the account
  • Get the above error, even though the key will work correctly

Expected vs actual behavior

I think there are a couple of ways that the handling of already registered keys could be improved:

  • Given the CLI app is granted full permission over the user's registered SSH keys, it could presumably list the already registered ones first and only attempt to register a new key if it wasn't already registered.
    Then the error would only occur if the key was registered on a different account (or you uploaded it via the web browser while also attempting to register the CLI app, which would be an odd thing to do)
  • Customise the error message when this step fails to say something like "key already in use (Note: this error is expected if this SSH key was already registered on your account)"
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250