git learning (a) - git server installation

1, mounted on CentOS git

1 , install git 
yum install git 
2 , see the git version 
git - Version
 3 , create a git user groups and users, used to run git service 
groupadd git 
adduser git - G git 
passwd git

2, create a ssh login credentials

Create a certificate ssh here, is created on the client, not created on the server.

1 , the user configuration and mailbox 

Git config - Global the user.name ' your name ' 
Git config - Global user.email ' your email address ' 

2 , then generates a public and private key 

SSH -keygen -t RSA -C " your email address " 

option to save the file path ssh, directly enter the default path, I chose the default path, that is the last line of the display, stored in the c drive. 
Open the folder to save the key, find id_rsa.pub file, this file on the server. 

3 , import certificates ssh 

collect all users need to log public key, the public key id_rsa.pub file located in the public key import /home/git/.ssh/ authorized_keys file. 

CD / Home / Git /  
mkdir .ssh 
the chmod 700 .ssh 
Touch .ssh /authorized_keys 
chmod 600 .ssh/authorized_keys
cat id_rsa.pub >> authorized_keys

3, initialization Git repository

Select an empty directory as a warehouse, where select / SRV directory. Execute the command: 

git the init - Bare test.git 

change the warehouse owner and permissions 

chown - R git: git test.git

 / SRV file also need to modify the job to git users, or push the time being given no authority. 

chown -R & lt Git: Git / SRV

4, prohibiting the use of ssh git account login

The significance here is prohibited for security of the server, the server can log in to avoid directly from the git ssh. 

Edit / etc / passwd file 
found: git: the X-: 1001 : 1001 : ,,,: / Home / git: / bin / bash 

instead: git: the X-: 1001 : 1001 : ,,,: / Home / git: / usr / bin / GIT- shell 

command may be used: modified ssh, ssh may need to restart to take effect 
SSH restart: Service sshd restart 
SSH start: service sshd start

5, clone warehouse

After the above steps are completed, the server can try to clone code down. 

git clone git @ ip address: /srv/test.git

 

Guess you like

Origin www.cnblogs.com/ljl-blog/p/12017814.html