Saturday, November 14, 2009

(Tortoisegit + Gitosis + msysgit) configuring - Adding windows users and creating repo

Cont. from previous post
Now you are ready to add users to the server.
It is not that much hard to add ubuntu users.
You just have to install git-core and by adding keys to the key directory. You can add users. If you are a windows user you have to do some installations. There are few ways to access repositories as windows user.

Clients using who use command prompt

First you should download msysgit from here and run the exe. Assume you downloaded the full version.

Give the path as your wish.
To run git commands at anywhere from your command prompt, define a path variable on environment variables Right Click on My Computer => Properties => Advanced => Environemnt Variables => Edit or New give the variable name as "PATH", and variable value "C:\msysgit\msysgit\bin", the bin folder of the msysgit installed. And add the "C:\msysgit\msysgit\mingw\bin" path also, that means, variable value will looks like, "C:\msysgit\msysgit\bin;C:\msysgit\msysgit\mingw\bin"

Then go to start => run => cmd type git and press enter. You will get result like,

Now you are ready to use git.

Adding user

First of all you have to create a key pair for your self. Get the command prompt and navigate to the msysgit folder to create .ssh directory.
C:\msysgit\msysgit\> mkdir .ssh

You are not allowed to create folders beginning with "." by right click => New => folder. So that it should be created this way.

Now navigate into the .ssh folder. We are going to create key pair.
C:\msysgit\msysgit\.ssh> ssh-keygen 
give id_rsa for the key name.
Following result will be shown.
Generating public/private rsa key pair.
Enter file in which to save the key (//.ssh/id_rsa): id_rsa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in id_rsa.
Your public key has been saved in
The key fingerprint is:
92:0c:83:16:16:14:04:51:30:42:da:5d:df:fd:fb:15 Janaka@XPWINDOWS7

Now you need to transfer the public key to the server where your gitosis administrator belongs. With previous posts, you might remember my username at version control is janaka. Following command will carry your key to that server's keydir directory.On my command prompt,
C:\msysgit\msysgit\.ssh>scp janaka@
(Assume is the server that installed gitosis) using this command or anyhow you can copy your key to keydir/ directory.
Don't change the names of the public and private keys of the(id_rsa, on your local machine. Keep it as it is on .ssh folder.
Now the administrators part,
Admin should allow this key to copy to server and rename it. When renaming, keep remember to give the same name that you are planing to add in .conf file. If new user is gituser1, then public key should be renamed to on server.
On the server, admin should enter the this user into a user list of gitosis.conf file. You can see how to create new repository and work groups in this link.
On gitosis.conf,
[group myteam]
members = gituser1
writable = my_current_project
member should be the name of the added public key(without .pub) and writable is the repository which are writable by this team. Group name is myteam.
Now administrator should add these key file and changed gitosis.conf file and push it to git user. Actually administrator just cloning the gitosis-admin part from the "git" user and after changes pushing it back. Here are the commands for admin,
janaka@versioncontrol~$ git clone git@
janaka@versioncontrol~$ cd gitosis-admin
janaka@versioncontrol~/gitosis-admin $ git add keydir/
janaka@versioncontrol~/gitosis-admin $ git add gitosis.conf
janaka@versioncontrol~/gitosis-admin $ git commit -a -m "Added gituser1 as a new user"
janaka@versioncontrol~/gitosis-admin $ git push
Now on the client side (gituser1) can check whether he had successfully added. On command prompt he can try to add a clone.
C:\MyFolder> git clone git@

If it imported my_current_project folder without asking any password for git user it is successfully worked. Issued can be occured,
  • Ask a password for git user- your keys are not matching recreate the key pairs and install keys accurately.

  • Giving no permissions error- You have not been added successfully for that group on gitosis.conf file. Reedit the conf file.

Widows clients using Gitosis

You can find post regarding this from here

Creating new repository and adding permission groups

will be discussed here


  1. C:\MyFolder> git clone git@

    should be
    C:\MyFolder> git clone gituser1@

  2. Ok...
    Thanks for the correction.... :)

  3. Thanks for your work,

    but i have problems with this part:
    "Ask a password for git user- your keys are not matching recreate the key pairs and install keys accurately."

    Tens of generated keys won't work under WinXP/7, and also on one Debian client. I've created the keys per ssh-keygen with OpenSSH in Debian.

    Whats going on right here?


  4. I think it should work...
    Hope you have copied the public key to the proper location on the server....