Skip to content

Instantly share code, notes, and snippets.

@andreibosco
Created December 2, 2024 15:51
Show Gist options
  • Save andreibosco/1eb5437add3ea72299a78979119a15cc to your computer and use it in GitHub Desktop.
Save andreibosco/1eb5437add3ea72299a78979119a15cc to your computer and use it in GitHub Desktop.
Different git identities/keys with 1password

How to configure git to use multiple identities/keys with 1Password

  • Edit ~/.ssh/config
  • Add an item for each SSH identity/key following this example (replace github with appropriate name):
Host github
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_github.pub
IdentitiesOnly yes
  • Open SSH identity on 1password.
  • Over cursor on the public key field, click on the chevron-down icon and click on Download.
  • Save .pub file in the location specified in the git config file.

To use identity

  • When accessing the git repository, replace the hostname (e.g., github.com) with the host value define (e.g., github).
  • Example: [email protected]:andreibosco/example.git becomes github.com:andreibosco/example.git

Note

  • The identity/key must have been configured on 1Password to be used with its SSH agent.
  • To do so, go to the SSH identity on 1password.
  • Click on the ... button next to Edit, and click on Configure for SSH agent.
  • Follow the instructions on the file to add the desired identity/key.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment