Non default ssh keypair for git on XCode 4
I'd like to use a specific public/private key pair on a project I am working on. I managed to get the XCode git repo working by copying my keypair to ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub but I would prefer to name them id_github/id_github.pub or something similar (and keep my existing default keypairs as id_rsa). This is easily achieved with the git commandline using ssh config file (http://help.github.com/multiple-ssh-keys/).
However I cannot see how to do this with XCode 4. I start it up, click "Connect to a repository" and if I specify ssh开发者_C百科://github:projectname (where github is an ssh config entry containing my username) it tells me that the "Host is unreachable".
Does anyone know how to do this or if it is at all possible in XCode?
You need to create a host configuration for github.
% man ssh_config
Create an entry in ~/.ssh/config, it would look something like this:
Host github
HostName github.com # or whatever
User git
IdentityFile /home/.ssh/id_github
You can then check out repositories from the CLI via
% git clone ssh://github:gitusername/projectname.git
Or in Xcode using the same URL signature.
On a side, you can also declare a non-standard port using the Port host config. This allows you to use scp over ssh on non-standard ports.
edit
One thing I did notice, is that sometimes Xcode claims it is unreachable on the first click, but by clicking "back" and trying again…it goes through. Noticed this on the most recent repo I set up.
You should be specifying the url with
git@github:username/projectname.git
instead of the ssh one you are specifying.
Hope this helps.
The most reasonable workaround for this is just to upload multiple keys to github. I didn't realize that was possible at the time I asked the question but it solves the problem for me.
Of course, just using the git command line is always optimal :)
精彩评论