So I use BitBucket.org both for my day job, and also for managing my private Git repos. (Since BB is free for personal private repo use, whereas GitHub charges for that…)
However, when I go to push to BitBucket for my personal use, I need to make sure that my SSH keys for work aren’t loaded. This has resulted in me doing things like “ssh-add -D” to wipe out all the keys in my ssh agent, then manually loading my personal key for git use. Then when I start work again, I have to reload my other keys. Rather annoying.
I came across a solution here: git admin: An alias for running git commands as a privileged SSH identity
However, it didn’t work for me. Took a bit to figure out why, but it came full circle back to the use of ssh-agent– even though I was properly specifying my SSH identity file, the keys from my ssh-agent were being seen first. All I had to do was to disable the use of ssh-agent inside of the ssh-as.sh script, like so:
#!/bin/bash set -e set -u unset SSH_AUTH_SOCK ssh -i $SSH_KEYFILE $@
That did the trick for me. Hope that helps someone else out there as well!