Categories

Meta

associate ssh key with git remote host

I often run into to issues where I like to use different ssh keys for different sites, servers, and other things. It is a good practice not to use the same key for everything just in case you need to change it, or other various reasons. If you are like me and don’t want to manually enter the path to theses keys each time you can associate them with a url. So if you were connecting via ssh, or over git with ssh it works perfectly.

So first generate a key. In this example we will create one for Bit Bucket.

ssh-keygen -f ~/.ssh/bitbucket

Now inside the ~/.ssh folder edit the config file and add the text below.

Host bitbucket.org
IdentityFile ~/.ssh/bitbucket
IdentitiesOnly yes

At this point when you push to bitbucket it will use this key.. For example if you added the remote repo as origin

git push origin master

It should prompt you for your ssh unlock pass phrase.

Published by

Ryein C. Goddard

I'm a programer, auto painter, trader, farmer, father, and futurist. I really like PHP for web development. For desktop/mobile development in my mind there is only 1 solution and that is Qt. If you haven't heard of it go download it for FREE :D It is a C++ framework with great development tools. I have a 66 mustang that I have been working on and fixing for the last 2 years. I am very interesting in the future of farming. I also have a daughter. If you want to know why I am a futurist check out The Venus Project.
View all posts by Ryein C. Goddard