⬆️ ⬇️

Windows.Git.Cygwin.SSH.Gitolite and User Guide

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:

image



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.

image



image



image



image



image



image



image



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.



  1. 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:

    image

    Exit the profile by pressing Ctrl + D or using the exit command.

  2. 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.

    image

    We start the SSH command server:

    image

    Copy the public part of the key to the git profile:

    image

    Check whether it turned out to configure as we need. Run the ssh git @ localhost command and wait for the terminal prompt

    from git

    image

    Everything turned out to be customized.

    If it does not work, go to paragraph 10.



5. Go to the result: Setting up Gitolite





6. Go to the result: Configure GitExtensions





7. Go to the result: setting the user



Now you need to configure the windows profile of the current user.

  1. Ensure that the Alexei file is in the .ssh / folder of the current profile c: /users/Alexei/.ssh/
  2. Make sure the config file is in the same folder.
  3. 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 \
  4. 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

    image
  5. 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.




8. Go to the result: Algorithm work for the admin repository





9. We look at the result





10. We look at the errors



  1. 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
  2. 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.
  3. 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.
  4. 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.
  5. 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



Source: https://habr.com/ru/post/125152/



All Articles