1. What is this article for?
The desire to get Git features on the Windows platform materialized the desire to tinker with different configuration schemes.
2. Awareness
You need to realize that you have to use the program Cygwin, SSH, GitExtenstions, Git, Gitolite
Cygwin is a program that emulates the Linux environment. It has its own black window that looks and works like a Linux terminal window.
MsysGit is a program for emulating the git environment, but without an ssh server, so we will not use repositories on the server. We use only for repository clients.
SSH is a program for using ssh connections from ssh clients and is available for all operating systems.
SSH server is a program that accepts connections from ssh clients.
Git is a set of programs, including git itself, for working with file repositories.
Gitolite is a program that wraps git and implements repository management functions: managing users, accessing them, and so on.
GitExtensions is a windows program, wrapping functionality like git, as well as the accompanying set of programs in a GUI, which also integrates into the Visual Studio 05/08/10 development environment.
')
The corporate will have to allocate resources for hosting the SSH service, disk space for hosting repositories.
The person who will serve the SSH server, access to the repository.
Teach users to use analog functions to interact with their old version control system through GitExtensions.
Offer them some schemes of work that Git allows to achieve.
UPD: 08/05/2011
UPD: 01/30/2012
3. Go to the result: Hosting for components
Git, SSH server, Gitolite will be hosted in Cygwin.
go to
http://cygwin.com/setup.exe
Run the installer.
Add a mirror
http://cygwin.vc.ukrtel.net/
matway.org - became unavailable. Updated January 30, 2012.
List of mirrors close to Russia:
cygwin.com/mirrors.html
Mark the following components:
Net | openssh
Devel | git
Devel | git-completion
Devel | git-gui
Devel | gitk
Editors | vim
Click Next and the installation will offer to add the necessary packages with which we agree and click Next.
Check Start Menu / Cygwin / Cygwin Terminal:
Login Alexei is my login in windows, base machine name. It all fits.
4. Go to the result: Setting up an SSH server
We start Cygwin Terminal.
We start the SSH server configuration using the ssh-host-config command.
Go to / etc / sshd-config and connect the authorization without a password:
Uncomment these lines:
PubkeyAuthentication yes
AuthorizedKeysFile .ssh / authorized_keys
For all users who will work with Git, you need to configure the entrance to the SSH server, through the user git (or other name) TV mode without a password.
A bit of theory about the operation of the SSH server.
When connecting from an SSH client via the git @ localhost connection string, the first thing that happens is
search for the private part of the key in the .ssh directory; if in CYGWIN, then ~ / .ssh /; if windows, then c: /users/yourname/.ssh
Next, in the authorized_keys file in the git profile on the localhost server, you search for text that has a marker equal to your current username. If it is located, then you get a terminal into which the git user profile is loaded.
There are clients in cygwin, in gitbash, there are such as putty. We are interested in the ssh client, which is in cygwin.
It is called by the ssh command with git @ localhost arguments, where git is the name of the user whose profile we want to log in via ssh and localhost (this is the address of the SSH server).
Actually, now we will make it work as it was said above.
- Enter another user named git. This name will be for service operations.
Open Computer managment -> Local User and Groups -> Users-> PCM -> New User ->
Git name, password 123456, check “Password never expires” -> OK
Open Cygwin Bash Shell, enter the command mkpasswd -l -u git >> / etc / passwd
We animate the user profile with the command:
Exit the profile by pressing Ctrl + D or using the exit command.
- We generate a key for our login. In my case for Alexei login.
The ssh-keygen -t rsa command will create a key in a folder that will consist of two files
id_rsa (private part, stored at you) and id_rsa.pub (public part of the key).
then we add the public part of the key to the authorized_keys file in the git user profile
via the ssh-copy-id -i git @ localhost command.
We start the SSH command server:
Copy the public part of the key to the git profile:
Check whether it turned out to configure as we need. Run the ssh git @ localhost command and wait for the terminal prompt
from git
Everything turned out to be customized.
If it does not work, go to paragraph 10.
5. Go to the result: Setting up Gitolite
- Now you need to install gitolite, it will also install and configure repositories for storing files. Go to / tmp and download the gitolite program using git:
Then go to / gitolite / src / and run ./gl-easy-install with the following keys
git localhost Alexei. git is the login where gitolite will be set, localhost address of the SSH server, Alexei username at the same time and the name of the private and public part of the key.
When asked to enter a password, then just press Enter, since the password is not needed anywhere.
- Next we go to the next installation screen.
This window shows the open .gitolite.rc file in the vim editor.
It is necessary to pass the cursor to the place of text insertion, press I , enter text
$ ENV {PATH} = "/ usr / local / bin: / usr / bin: / bin";
The text must be entered without errors, otherwise you will get confused in this editor.
For simplicity, you can copy the text, then move the cursor to the right place, press I, then click on
the black window icon (terminal, command line, etc.) select edit-> paste and paste the line.
Press after entering ESC, press shift +:, type wq, press Enter.
This line will allow gitolite to call programs from the cygwin environment, which have similar names with windows programs. For example, the find command is both there and there. And if you do not specify, gitolite will work with errors, and even the installation program will work with errors, since the find from windows will be used.
Press Enter several times and get the following image:
6. Go to the result: Configure GitExtensions
- Now let's move on to installing GitExtensions at http://code.google.com/p/gitextensions/
We put it with msysgit, gitextensions will use it, after setup.
Also note openssh in favor of putty.
Setting up a user and email for GitExtensions will not be considered.
Everything is going smoothly there.
7. Go to the result: setting the user
Now you need to configure the windows profile of the current user.
- Ensure that the Alexei file is in the .ssh / folder of the current profile c: /users/Alexei/.ssh/
- Make sure the config file is in the same folder.
- in order to do this, you need to take them from c: \ cygwin \ home \ yourname \ .ssh \ config and yourname
and copy to c: \ users \ yourname \ .ssh \ - This is an option for the case when part of the work has already been done for us, in this case the gitolite program.
at the beginning, it generated for us your name and your .pub key files. I sent the pub version to the git profile's authrozied_keys file.
and also added settings to this key in authorized_keys.
Let's see this modified authorized_keys

- Explanation of information.
The private parts of the keys are placed in blocks marked at the end: for which user and from what address.
The first one is from my first key id_rsa.pub.
The second privatka is from the key Alexei.pub, which has already been done by gitolite itself; As you can see, gitolite adds extended information to the key, which ensures the entire interaction of the system.
- To set up a new user, he needs to install for ease: gitextensions with msysgit and openssh enabled.
Next you need to configure the user key to log in to the git profile on localhost.
To do this, open start menu-> git -> git bash and enter ssh-keygen -t rsa, we get two key files.
Give the pub file to the person who serves git.
8. Go to the result: Algorithm work for the admin repository
- This person should take the pub file, put it in the folder of the local repository gitolite-admin \ keydir.
This folder will already be created in the user profile where the installation was launched from.
Register the file name in gitolite.conf and send via git push to the repository.
Then gitolite will create settings in its gitolite.conf.pm, authorized_keys, etc. files in the git user profile.
We can assume that the user is set up correctly in the system and from under it you can work in windows.
To work from cygwin, you need to copy all the files relative to /home/user/.ssh/
9. We look at the result
- To see, you have to try.
Run GitExtensions.
Configuring it on the Git tab should be as follows:
This folder appears if you install mSysGit together with GitExtensions (you need to install it for each client).
We select clone repository, in the address we put git @ gitolite: testing.git, any destination folder.
click clone and get an empty testing repository.
and you can get this window:
Which means a security violation in an ssh connection.
In this case, our SSH server is on our computer, so to quickly solve this problem, delete the file c: \ users \ Alexei \ .ssh \ known_hosts, try again to make Clone.
The following window will appear:
Click yes and Enter.
The following window will appear:
The information in it means that the whole chain is working.
Open the d: \ test.rep folder and see that there is a hidden .git folder, which means success.
- Why in the address git @ gitolite, gitolite, but not localhost? because there is a config file in which the setting is written for the word gitolite. If the ssh client sees that we have specified a word in the server address that is similar to the one in the config, then it applies the settings from this file. In principle, you can not use the config, then the private key will be called by default id_rsa and server address localhost (or ip address). And it will look like git @ localhost. But you can't do that. Since gitolite will not understand who is who. Therefore, all instead of id_rsa is a file with a private part, and its name is different from all others.
Look at the file:
10. We look at the errors
- SSH and login with password
All because of the broken authorized_keys.
or ssh server settings, which include the use of the authorized_keys file.
if we are at the git user setup stage, then we use ssh-copy id, which saves the pub version of the key and edits the authorized_keys. If you have already installed the entire ecosystem, then:
/home/git/.gitolite/src/gl-setup-authkeys -batch /home/git/.gitolite/keydir - An address of the form git @ gitolite is not accepted: testing.git
/home/git/.gitolite/src/gl-setup-authkeys -batch /home/git/.gitolite/keydir
All because of the broken authorized_keys. Generate it with this command again. - Constantly lost input without a password from cygwin bash shell
/home/git/.gitolite/src/gl-setup-authkeys -batch /home/git/.gitolite/keydir
All because of the broken authorized_keys, generate it with the help of this command again.
Also, you may not have installed the following entry in gitolite.rc:
$ENV{PATH}="/usr/local/bin:/usr/bin:/bin";
Put it in the means available to you. - Synchronize users between Windows and Cygwin
mkpasswd -l> / etc / passwd
It is necessary if you want to reassign the logins for the ssh server and the service login for the gitolite system. - Remove SSH server
cygrunsrv -R sshd
This will remove only the cygserver ssh service from windows, but the login will remain.
To do this, you still need to clear / etc / ssh * of files.
Remove the cygserver login from windows and synchronize / etc / passwd with the command
mkpasswd -l >/etc/passwd
A little note about the big Nyance
- The mkpasswd command writes the path to the login directory to the / etc / passwd file.
If the default cygwin \ home folder doesn’t fit, you can specify the c: \ users \ folder for Windows7 or another with the -p "$ (cygpath -H)" switch when you create a git user.
mkpasswd -l -p "$(cygpath -H)" > /etc/passwd
- Also in this article, the installation scheme is used, when the ssh server and the user are on the same computer. Which leads to another strategy. By default, your Cygwin username looks into the cygwin \ home \% username% folder, in the article this is bypassed using msysgit, which has your username looking into the c: \ users \% username% folder (for win7), so your copies are made keys from cygwin \ home \% username% in c: \ users \% username% (p. 7.3). If you send the home folder to Cygwin for your login on c: \ users \% username%, then the need for msysgit will disappear.
With finishes completed.