Install git server on centos

Source: Internet
Author: User
Tags git client using git

1. Yum install lrzsz wget git

2. Install gitosis: gitosis is a git user permission management system. It manages user permissions by managing the/home/git/. Ssh/authorized_key file on the server. It is a python module package.

# Yum install Python-setuptools

# Git clone git: // github.com/res0nat0r/gitosis.git

# Cd gitosis/

# Python setup. py install

If finished processing dependencies for gitosis = 0.2 is displayed, the request is successful.

 

3.

To access gitolite, you must use an SSH key for verification. If there is no key (a public key and a private key) on the computer used as the GIT client, you can use the ssh-keygen command to generate the key and copy it to the GIT server.

$ Ssh-keygen-t rsa "[email protected]"

Here we do not specify the name of the generated key file (which can be specified through-f filename). Therefore, the generated file is id_rsa and id_rsa.pub. The former is the private key and the latter is the public key. In addition, execute ssh-keygen in Linux to specify the email address of the key owner at the same time, which will appear in the SSH public key content.

On the GIT server built by gitolite, you create a new code library by modifying the source code in the code library of the gitolite-admin.git and adding the login public key to git clients. To manage gitolite, you must have a git virtual user to clone the gitolite-admin.git code from git, which requires a pair of SSH keys to be created on the server's local machine.

 

Add a git user

Adduser -- System -- shell/bin/sh -- Comment 'git version control' -- create-home -- home-DIR/home/git

CD/home/git

Rz select your generated ssh-Key

 

4. Su git

gitosis-init < ./id_rsa.pubchmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update


5. Use puttykeygenerator to convert pub to PPK

Putty is a private key file generated in Linux. Putty only recognizes its own PPK format. to convert the two formats, you need puttygen.

 

When installing tortoisegit, a selection item is displayed:

If you select the first option, you need to pay attention to some things When configuring git after installation. If you select the second option, the GIT connection is completed through SSH, and the subsequent configuration is simpler.

In plink mode, PPK needs to be loaded during git clone.

Putty key generation method:

Start putty key generator

Click the Load button to load the SSH key generated first.Id_rsaFile Import. In the displayed dialog box, the import is successful. Click Save private key to save the PPK file, and then load the PPK file in the GIT clone dialog box, during the connection, you will be prompted to enter the GIT user's password and enter it to clone the gitosis configuration file.

If you select tortoisegit in SSH mode, you do not need to configure PPK and clone it directly by using git.

Here you need to note when entering the git url in the dialog box, it is to write the gitosis-admin.git directly, rather than adding the absolute path of/home/git.

 

6. If git clone is performed directly on the Linux server, pay attention to the path problem:

 

Git clone [email protected]:/home/git/repositories/gitosis-admin.git

Otherwise, the following message is displayed:

1 fatal: ‘gitosis-admin.git‘ does not appear to be a git repository
2 fatal: The remote end hung up unexpectedly

 

In Windows, do not add the user name or absolute path. Otherwise, an error is reported.

Error: gitosis. Serve. Main: Repository read access denied

 

Git clone [email protected]: gitosis-admin.git

 

 

7. gitosis. conf

[Gitosis]

[Group gitosis-admin]
Writable = gitosis-Admin
Members = [email protected] # display that the user [email protected] is the owner of the initialized gitosis public key and the only person who can manage the gitosis-Admin Project

[Group jay_fans] # group name
Members = [email protected] # Separate multiple key usernames with spaces [email protected] [email protected]
Writable = Git-test # project name

 

 

Iii. FAQs

First make sure that/home/git/repositories/gitosis-admin.git/hooks/post-update is executable and the property is 0755
1. Enter the password for git operations
Cause
Public Key not found
Solution
Upload id_pub.rsa to keydir and change it to 'gitosis account. pub', for example, Miao. Pub. Extension. Pub cannot be omitted
2. Error: gitosis. Serve. Main: Repository read access denied
Cause
Members in gitosis. conf is inconsistent with the user name in keydir, for example, members = [email protected] In gitosis, but the public secret name in keydir is foo. Pub
Solution
Make the keydir name consistent with the name specified by members in gitosis.
Change members = Foo or public key name to [email protected]

 

(3) 'gitosis-admin' does not appear to be a git repository appears. If the short path is invalid, replace it with the full path.

Using a short path on the server will find the following problem, because the corresponding matching key is not found. If the SSH key is used correctly, this problem will not occur and will not be involved here.

[email protected]:/home/git/repositories# git clone [email protected]:gitosis-admin.gitCloning into gitosis-admin...[email protected]‘s password:fatal: ‘gitosis-admin‘ does not appear to be a git repositoryfatal: The remote end hung up unexpectedly

Use the following command to solve the problem, but each time you push and pull, you need to enter the GIT user password, which is a little tedious.

git clone [email protected]:/home/git/repositories/gitosis-admin.git

(4) the following error occurs: Unable to create temporary file: Permission denied.
The following error occurs when tortoisegit is used for push on Windows.

git.exe push --force --progress  "origin" master:masterCounting objects: 189, done.Compressing objects: 100% (187/187)Writing objects:   7% (14/189)fatal: Unable to create temporary file: Permission deniedfatal: sha1 file ‘<stdout>‘ write error: Invalid argumenterror: failed to push some refs to ‘[email protected]:channelv.git‘git did not exit cleanly (exit code 1)

It turns out that the database directory created with the root account is on the server, so the GIT account has no permission to write data. The method is to modify the user and User Group of the folder.

[email protected]:/home/git/repositories# chown -R git *[email protected]:/home/git/repositories# chgrp -R git *

(5) failed to push some refs to '[email protected]: ChannelV. Git' appears'

The following error occurs when tortoisegit is used for push on Windows.

git.exe push --progress  "origin" master:masterCounting objects: 189, done.Compressing objects: 100% (158/158)Writing objects: 100% (189/189), 1016.00 KiB | 997 KiB/sWriting objects: 100% (189/189), 1.12 MiB | 997 KiB/s, done.remote: error: ‘receive.denyCurrentBranch‘ configuration variable to ‘refuse‘.To [email protected]:channelv.git! [remote rejected] master -> master (branch is currently checked out)error: failed to push some refs to ‘[email protected]:channelv.git‘git did not exit cleanly (exit code 1)

Run the following command in the database directory corresponding to the server to add the configuration.

git config --bool core.bare true


6. "agent admitted failure to sign using the key" may occur when git clone the gitolite-admin.git code, and then let's enter the hosting user password.

$ Git clone [email protected]: gitolite-admin.git
Cloning into 'gitolite-admin '...
Agent admitted failure to sign using the key.
[Email protected]'s password:
Permission denied, please try again.
[Email protected]'s password:
Permission denied, please try again.
[Email protected]'s password:
Permission denied (publickey, password ).
Fatal: the remote end hung up unexpectedly
$

This is an SSH issue. Solution provided in reference [3:

Https://help.github.com/articles/error-agent-admitted-failure-to-sign

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.