Chosing which SSH key to use

Community Member
edited June 22 in SSH

Hi there,

I have been a 1password user for many years and it't one of my favorite productivity tools. I decided to migrate my SSH keys to it and it works really nicely, but I have found an issue.

I have two Github accounts that I use with SSH keys. GitHub won't let me add the same key for multiple accounts for obvious reasons, so I need to have separate keys for each of the accounts.

But when using 1password SSH agent, it always choose the same key.

Is there a way to prompt which key I should use? That way I can just select the key when running git commands.

Thanks for the help

1Password Version: 1Password for Mac 8.8.0 80800143, on BETA channel
Extension Version: 2.3.5
OS Version: macOS 12.14


    Community Member

    Using IndentifyFile in your ~/.ssh/config file should work.

  • purrpledevpurrpledev
    Community Member

    Indeed I could use IdentifyFile and a custom git host for that, but if 1p had an option to choose somehow, it would make things a lot more seamless. If that functionality doesn't yet exists maybe I should open a feature request. Thanks for suggestion, though. It will do for now :)

  • simon_1Psimon_1P

    Team Member

    Hi @purrpledev, @XIII is right that you can leverage the SSH configuration to achieve this. Here's four steps to take to achieve this:

    1. Download the public key for both SSH key items:
    Download your public key
    1. Move the public keys to your ~/.ssh/ directory.

    2. Configure hosts for your personal and work GitHub profile by appending the following to your ~/.ssh/config:

    # Personal GitHub
    Host personalgit
      User git
      IdentityFile ~/.ssh/
      IdentitiesOnly yes
    # Work GitHub
    Host workgit
      User git
      IdentityFile ~/.ssh/
      IdentitiesOnly yes

    Make sure the IdentityFile matches the names of the files at step 2.

    1. For each repo, change the git URL to use one of the new hosts instead of [email protected]:
    git remote set-url origin <host>:<workplace>/<repo>.git

    For example:

    git remote set-url origin personalgit:1password/1password-teams-open-source.git

    Now your SSH clients will know which SSH key to use for each repository and the right GitHub account will be used for each.

    I'll also file a feature request on your behalf to explore if we can detect the duplicate configuration and prompt for you to pick an SSH key if so.

  • simon_1Psimon_1P

    Team Member

    I'll move this thread over to the SSH topic, as the 1Password SSH agent is shipped with 1Password 8 and is independent of 1Password CLI.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file