1

I use GitLab repositories with two users (myself and a test user). For my test repository I have this in .git/config:

[core]
    sshCommand = ssh -i /test-project/test_id_rsa
[remote "origin"]
    url = git@example.com:test.tester/test-repo.git

And I don't use a passphrase at all with test_id_rsa.

'git pull', etc. works fine, but only when keychain is not running. When keychain is running, it seems my usual SSH key gets used, and Git commands will not work, as I come across as wrong key pair is used.

Without keychain:

lynoure@laptop:~/repo$ ssh -i ~/.ssh/a_test.tester_key git@gitlab.example.com
Welcome to GitLab, test tester!
Connection to gitlab.example.com closed.

I start keychain with the shell, by:

eval `keychain --eval --agents ssh id_rsa

When I have started keychain:

lynoure@laptop:~/repo$ ssh -i ~/.ssh/a_test.tester_key git@gitlab.example.com
Welcome to GitLab, Lynoure!
Connection to gitlab.example.com closed.

Is there some way I can avoid needing to disable keychain every time I use my test-repo in the tests?

migrated from stackoverflow.com Oct 2 '17 at 13:15

This question came from our site for professional and enthusiast programmers.

1

If this is a key that one reasonably often, the trick is to add that key to keychain:

eval `keychain --eval --agents ssh id_rsa a_test.tester_key

After that, the right key will get used.

If one uses a key less often, or uses a lot of different keys, best just to stop keychain for that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.