GIT_SSH_COMMAND
April 21, 2023
If you want to use multiple GitHub accounts, and have your ssh keys stored
in 1Password, the environment variable GIT_SSH_COMMAND
can be used as an alternative to modify your
~/.ssh/config
file
For example if you need to use key1
for project1
define it like this:
export GIT_SSH_COMMAND="ssh -i ~/.ssh/key1.pub -F none"
you can add it to your
.envrc
and make it global for all projects within a directory.
The option -F none
or -F /dev/null
makes that no configuration file will be read.
If you then do:
ssh -T [email protected]
It will use the key from user key1
without the need to modify to changte the git URL.