Skip to content

Uploading an existing key to a new account fails silently #4792

@jawnothin

Description

@jawnothin

Describe the bug

When running gh auth login and it uploads the SSH key to the account, if it's already registered on another account it just proceeds without error.

Steps to reproduce the behavior

  1. Generate an SSH key
  2. Create an account, and upload the ssh key
  3. Create another account, and run gh auth login
  4. Upload the same SSH key that's already on another account

Expected vs actual behavior

Expected: An error is generated showing "Key is already in use", remove from other account or use a different key.

Logs

> gh auth login
? What account do you want to log into? GitHub.com
? What is your preferred protocol for Git operations? SSH
? Upload your SSH public key to your GitHub account? id_rsa.pub
? How would you like to authenticate GitHub CLI? Login with a web browser

! First copy your one-time code: A2F6-B5E3
- Press Enter to open github.com in your browser...
✓ Authentication complete. Press Enter to continue...

- gh config set -h github.com git_protocol ssh
✓ Configured git protocol
✓ Uploaded the SSH key to your GitHub account: id_rsa.pub
✓ Logged in as account

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issuehelp wantedContributions welcomepriority-3Affects a small number of users or is largely cosmetic

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions