Signing back into the Community for the first time? You'll need to reset your password to access your account. Find out more.
Forum Discussion
stonesbg
3 months agoNew Contributor
1Password SSH Agent how to set specific ssh key
I have a few different ssh keys that are used for git and would like to have it set so that if going through one github organization i force one key if going to a personal account it uses a different key.
Is there any way as part of the IdentityAgent to specify the appropriate key or is the option just to keep cycling through the prompts for ssh keys?
1Password Version: Not Provided
Extension Version: Not Provided
OS Version: Not Provided
Browser: Not Provided
- jc00keOccasional Contributor
I've been able to achieve this with git's conditional includes. Here's what a config may look like:
# ~/.config/git/config
[include]
path = base-config.inc
[includeIf "hasconfig:remote.*.url:*:jc00ke/**"]
path = personal-config.inc
[includeIf "hasconfig:remote.*.url:*:WORK/**"]
path = work-config.inc
# ~/.config/git/personal-config.inc
[user]
name = Jesse Cooke
email = jesse@example.com
signingkey = ~/.ssh/personal.pubkey
# ~/.config/git/work-config.inc
[user]
name = Jesse Cooke
email = jesse@work.example.com
signingkey = ~/.ssh/work.pubkeyHere's my real dotfiles; this has worked for me for a while now.
- Michael_MercuriFrequent Contributor
You can specify which key to use for which host in
~/.ssh/config
usingIdentityFile
option, where the identity file is the public key to use and the private key is stored in 1Password. You may also need to specifyIdentitiesOnly yes
.Example for user99@example.com:
Host example.com
User user99
IdentityFile ~/.ssh/identity.pub
IdentitiesOnly yes
More here:
https://linux.die.net/man/5/ssh_config