Install the Git server with private key authentication on CentOS 6.2

Source: Internet
Author: User
Tags git client


A. installer file sudo yum install git python-setuptoolscd/optsudo git clone https://github.com/res0nat0r/gitosis.gitcd gitosis/sudo python setup. py install
B. Add a git user. Do not set a password for the git user so that the user cannot log on. After sudo adduser-m git www.2cto.com successfully creates a git user, You need to log on to the root account before su-git.
C. Install the Git client and TortoiseGit (take Windows as an example) on the client to generate a public key and private key ),
First, you need to generate a public key private key pair through Git Bash (all the parameters to be entered are left blank): the ssh-keygen command will be in the current user directory. the id_rsa and id_rsa.pub files are generated in the ssh directory,
To enable TortoiseGit to use the private key, you also need to use the Puttygen tool of TortoiseGit to generate the putty private key based on the id_rsa file,
Save it as a. ppk file:

D. to initialize the gitosis environment, first upload the generated public key to the server, open the id_rsa.pub file, and check the Last User Name of the content,
For example, the. pub file I generated is like this: ssh-rsaAAAAB3NzaC1yc2EAAAABIwAAAQEAzX7 // rMabzT5CUGdX + oiEq3k3el56yanqcwtpIfQYVJ09pu/
1Se2zLCQBVjav10a3bsURoNWE/kqC6znBDtaC5wl8MdhT8hW5 + YpMHT0ub6G3UkYJLD4vW7z + J/
ZiFazSTJEpn/yaalj8tl880ho8bu + CTUdV0bPrFDngbUakjKTPH4l/vLLYdirrQ1uh/
FmZOUWBLr8 + JbbFYUZ3SKyID1reS5ekf + 7H5w + R0qGJPLeXVzdyKPWY/KHFc/
T0nWKxKAZY0cNgdXgjlgZCqEI2 + yrtEw + SyBaSz9bx2XwoSkDK0Z2As +
68RslrYNOhkpvn5XkWhdIHc3H2N6mIzP2w = wuyf @ WUYFWIN so renamed the public key file name as a wuyf@WUYFWIN.pub and uploaded it to the server, such as the/tmp directory,
Then use this user to initialize gitosis: sudo-H-u git gitosis-init </tmp/wuyf \ @ WUYFWIN. pub has initialized the gitosis-admin repository for managing git accounts in the repositories directory of the git main directory. Www.2cto.com
E. Clone the gitosis-admin repository and configure it. Now you can clone the gitosis-admin repository to your local machine and configure it. Note that in the TortoiseGit client
You need to load the private key in ppk format generated above:

If you want to add other users, execute the above steps C generate a public key private key pair on the client on other user machines,
Add the. pub Public Key to the keydir directory of the gitosis-admin repository, and add the. pub Public Key to the gitosis. conf file.
Configure the corresponding group for it. The following is a gitosis. example configuration of conf: [gitosis] [group gitosis-admin] writable = gitosis-adminmembers = wuyf @ WUYFWIN [group test] writable = maventestcitestmembers = wuyf @ WUYFWIN xxx @ YYY
F. Create another new repository and use the root user to remotely log on to the server. Switch to the git user su-www.2cto.com su-gitcd ~ /Repositoriesmkdir test. gitcd test. in gitgit init -- bare, the repository can be cloned and used on the client machine. The repository address is git @ git_server_name: repository_name.git, where git_server_name is the machine name or IP address of the git server, repository_name is the specified repository name. Author warrenwyf

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.