Reputation: 6201
I have a development machine "Laptop" and here I have an SSH key for my git account in Bitbucket. I also have a production server "Server" where I do not want to use this key, instead I want to use another key with read-only permissions in Bitbucket.
My expected workflow was to use SSH to log onto Server and there I would run git pull
. It works just fine. However, when I log out and try to do git push
from Laptop, the push is rejected because I don't have write permissions. Using GIT_SSH_COMMAND="ssh -vv" git push
and ssh-add -l
, I have found out, that if I add the read-only SSH key on the server, it also appears on my Laptop, so when I push, the read-only key is used. When I remove it from Laptop using ssh-add -D
it is no longer available on Server either. So it seems that when I am logged to Server, the SSH agent always uses my Laptop configuration.
How can I prevent this? When I am logged to Server, I want to use Server's read-only ssh key, when I am on Laptop, I want to use my personal's ssh key.
I tried changing /etc/ssh/ssh_config
to include
Host bitbucket.org
ForwardAgent no
but it doesn't help me.
I tried looking for other questions but everyone has the opposite issue and they are trying to sync the keys instead, so I couldn't find an answer.
Thanks for any tips.
Upvotes: 4
Views: 77
Reputation: 2995
Have you tried IdentityFile /path/to/key
?
By the way, you should NOT update /etc/ssh/ssh_config
, creating a ~/.ssh/config
is a better option (and recommanded).
Also you should have a different config on "Server" and "Laptop".
Upvotes: 2