How to tell git which private key to use?
ssh has the -i option to tell which private key file to use when authenticating:-i identity_fileSelects a file from which the identity (private key) for RSA or DSA authentication is read. The default...
View ArticleAnswer by Ignacio Vazquez-Abrams for How to tell git which private key to use?
Write a script that calls ssh with the arguments you want, and put the filename of the script in $GIT_SSH. Or just put your configuration in ~/.ssh/config.
View ArticleAnswer by shellholic for How to tell git which private key to use?
In ~/.ssh/config, add:Host github.com HostName github.com IdentityFile ~/.ssh/id_rsa_githubIf the config file is new, check access permissions usingstat -c %a ~/.ssh/configif returns NOT 600, you...
View ArticleAnswer by rabexc for How to tell git which private key to use?
You can just use ssh-ident instead of creating your own wrapper.You can read more at:https://github.com/ccontavalli/ssh-identIt loads ssh keys on demand when first needed, once, even with multiple...
View ArticleAnswer by kenorb for How to tell git which private key to use?
There is no direct way to tell git which private key to use, because it relies on ssh for repository authentication. However, there are still a few ways to achieve your goal:Option 1: ssh-agentYou can...
View ArticleAnswer by Flimm for How to tell git which private key to use?
Environment variable GIT_SSH_COMMANDFrom Git version 2.3.0, you can use the environment variable GIT_SSH_COMMAND like this:GIT_SSH_COMMAND="ssh -i ~/.ssh/id_rsa_example" git clone exampleNote that -i...
View ArticleAnswer by Jan Vlcinsky for How to tell git which private key to use?
After my struggle with $GIT_SSH I would like to share what worked for me.Through my examples I will assume you have your private key located at/home/user/.ssh/jenkinsError to avoid: GIT_SSH value...
View ArticleAnswer by flaviovs for How to tell git which private key to use?
If you do not want to have to specify environment variables every time you run git, do not want another wrapper script, do not/can not run ssh-agent(1), nor want to download another package just for...
View ArticleAnswer by Salsicha for How to tell git which private key to use?
My solution was this:create a script:#!/bin/bashKEY=dafault_key_to_be_usedPORT=10022 #default port...for i in $@;do case $i in --port=*) PORT="${i:7}";; --key=*)KEY="${i:6}";; esacdoneexport...
View ArticleAnswer by Zaz for How to tell git which private key to use?
Generally, you want to use ~/.ssh/config for this. Simply pair server addresses with the keys you want to use for them as follows:Host github.com IdentityFile ~/.ssh/id_rsa.githubHost heroku.com...
View ArticleAnswer by thucnguyen for How to tell git which private key to use?
Use custom host config in ~/.ssh/config, like this:Host gitlab-as-thuc HostName github.com User git IdentityFile ~/.ssh/id_rsa.thuc IdentitiesOnly yesthen use your custom hostname like this:git remote...
View ArticleAnswer by Michael Cole for How to tell git which private key to use?
I had a client that needed a separate github account. So I needed to use a separate key just for this one project.My solution was to add this to my .zshrc / .bashrc:alias infogit="GIT_SSH_COMMAND=\"ssh...
View ArticleAnswer by miguelmorin for How to tell git which private key to use?
I build on @shellholic and this SO thread with a few teaks. I use GitHub as an example and assume that you have a private key in ~/.ssh/github (otherwise, see this SO thread) and that you added the...
View ArticleAnswer by akjprajapati for How to tell git which private key to use?
I'm using git version 2.16 and I don't need a single piece of script not even a config or modified commands.Just copied my private key to .ssh/id_rsaset permissions to 600 And git reads to key...
View ArticleAnswer by Jinmiao Luo for How to tell git which private key to use?
Just use ssh-agent and ssh-add commands.# create an agentssh-agent# add your default keyssh-add ~/.ssh/id_rsa# add your second keyssh-add ~/.ssh/<your key name>After executing the above commands,...
View ArticleAnswer by Brendan Baldwin for How to tell git which private key to use?
So I set the GIT_SSH env variable to $HOME/bin/git-ssh.In order to support having my repo configuration dictate which ssh identity to use, my ~/bin/git-ssh file is this:#!/bin/shssh -i $(git config...
View ArticleAnswer by dtmland for How to tell git which private key to use?
While the question doesn't request it, I am including this answer for anyone else looking to solve the same problem just specifically for gitlab.The gitlab solutionI tried using the...
View ArticleAnswer by Srikrushna for How to tell git which private key to use?
When you have multiple git account and you want different ssh keyYou have to follow same step for generating the ssh key, but be sureyoussh-keygen -t ed25519 -C your-email-id@gmail.comEnter the path...
View ArticleAnswer by Yordan Georgiev for How to tell git which private key to use?
# start :: how-to use different ssh identity files # create the company identity file ssh-keygen -t rsa -b 4096 -C "first.last@corp.com" # save private key to ~/.ssh/id_rsa.corp, cat...
View ArticleAnswer by nyxz for How to tell git which private key to use?
If you need to connect to the same host with different keys then you can achieve it by:Configure the ~/.ssh/config with different Hosts but same HostNames.Clone your repo using the appropriate...
View Article