Eclipse, EGit, gitolite, git
Sorry this post will be in english.
We have a server with some git repositories in, and these repositories are being managed with gitolite. Gitolite uses SSH2 public keys to authenticate users, so each time a new user want access to a repo, she has to tell to our system administrator (probably creating and/or sending her public SSH2 key to our sysadmin). Then, our sysadmin would tweak with gitolite, adding the user/key to gitolite or just grant the required access to a repo.
In the case that you use Eclipse with the EGit plugin, you’ll notice it’s not straightforward to configure it. Here i put the steps we followed to have it running:
0 – Assumptions
If our server is http://ourgreatserver.com, we usually type this command to clone a repository on a developer machine:
$ git clone email@example.com:myProject
Note that we have a user on the server, called gituser. With this user we have a regular account with SSH access, but we also use this user to manage gitolite. Also we have configured gitolite to place the git repositories under /home/gituser/repositories.
So the repo myProject is located at /home/gituser/repositories/myProject.git
That said, we followed the next steps:
1.Generate the SSH2 key pair on Windows
In the case we need to generate both public and private SSH2 keys from our windows development machine, we download puttygen.exe and run it:
1.1. We’re not using password, but we can specify one if we want to protect out keys. We do not use a password here because our gituser user has it’s own for SSH access and we don’t need the overhead of using another one.
1.2. Click on the “generate” button and move your mouse over the progression bar and the space below it (yes, this is strange but necessary).
1.3. Save both the public and the private key into a well known (and secure) folder. Don’t forget them! WE RECOMMEND TO SAVE THEM INSIDE C:/Users/fabi/.ssh (note that fabi is the username).
1.3.1. The private key should never be out of your control. If anyone/anything asks you about a key, you should only provide the public one (as a rule of thumb).
2. Configure gitolite on the server to accept this new user
For this step, you’ll probably want to send your public key to your gitolite server administrator.
3. Download and install Eclipse.
4. Configure SSH keys in Eclipse
In order to use the pair of SSH keys you’ve just created, we must configure Eclipse:
4.1. Open “Window->Preferences”
4.2. On the left side of the screen there’s a tree view of all the configuration options. Open the “General->Network Connections->SSH2”
4.3. Inside the SSH2 configuration options, select the “General” tab.
4.4. For the “SSH2 home” field, browse to the dir where you saved your keys pair.
4.5. The “Private keys” field should be showing something like “id_dsa, id_rsa”.
5. Download and install EGit for Eclipse (you can do this from within Eclipse Marketplace).
6. Open the “EGit” perspective from Eclipse and click on “Clone a Repository”. Then fill the following text fields:
Repository path: myProject (or any other repo)
** This step is optional **
7. If we want to use git from the command-line in Windows, a good way to go is to download and install msysgit from here:
3.1. We prefer the full install. When installing, we select the “Just use git-bash” option. If you want to know more on this step, please refer to the documentation at the msysGit web page.
3.2. In our Start Menu we should have a git-bash execuable.
Hope all of this will be helpful.