I interact with two different git repositories, both of them are GitLab implementation.
Since I need to use different users (and e-mail) to access them, I created two ssh keys: let's say id_rsa_1
and id_rsa_2
. After that I wrote a ~/.ssh/config
file to specify when each id_rsa file should be used. config file is:
Host gitlab.host1.com-user1
HostName gitlab.host1.com
User user1
IdentityFile ~/.ssh/id_rsa_1
Host gitlab.host2.com-user2
HostName gitlab.host2.com
User user2
IdentityFile ~/.ssh/id_rsa_2
My problem is every time I use git
, that config
file aren't take into account. It is always looking for id_rsa file.
What is wrong in my config file?
Is Host
just a personal identifier or is it take into account during git
searching for keys?
Which user should I provide? "git" or my real user registered in each server?
What is really wrong in my config
file?
Thank you very much in advance.
The Host
entry is a pattern that is matched to what host you request when looking for keys. Then, HostName
is what host is actually logged into, and defaults to the value for Host
. So, you could say:
Host gitlab.host1.com
User user1
IdentityFile ~/.ssh/id_rsa_1
You could also specify gitlab.host1.com-user1
as the host when you call git, and it should work with your current config.
For more info, you can check man ssh_config
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With