CentOS Setup git full version

Source: Internet
Author: User
Tags scp command



Git Server Setup:



Http://www.centoscn.com/CentosServer/ftp/2014/0414/2789.html



http://871421448.iteye.com/blog/1912205



Http://weizhifeng.tumblr.com/post/25209375100/host-git-repositories-on-gitosis





1. Environment Deployment



System environment: Server side: CentOS 6.5, ip:172.20.48.15



Client: CentOS 6.5, ip:172.20.48.18



Software version: Server-side: source code compiled and installed, git-1.9.0.tar.gz



Client: Yum Online installation mechanism






2. installation (server side)



Install Git



#yum Install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel



#Wget: http://distfiles.macports.org/git/



#tar ZXVF git-1.9.0.tar.gz



#cd git-1.9.0



#make prefix=/usr/local All



#make prefix=/usr/local Install #root用户运行



View version number: Git--version



git version 1.9.0






Installing Gitosis



Gitosis for the GIT User Rights management system, through the management service side of the/home/git/.ssh/authorized_key file to perform the management of user rights, is a Python module package



#yum Install Python Python-setuptools



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



#cd gitosis/



#python setup.py Install



Show finished processing dependencies for gitosis==0.2 is successful









Install git (client):



#yum Install git



#git--version



git version 1.7.1









3. SSH settings (client secret, server public key)



Client:



#scp ~/.ssh/id_rsa.pub [Email protected]:~/



Server :



#ssh-keygen-t RSA



# CP id_rsa.pub/tmp/






4. Build a git user on the server



Add user git:



#useradd-D/home/git git



#chown Git:git/home/git






Modify path so that git users can call git:


Vi/home/git/.bashrc
Path=/usr/local/bin:/usr/local/git/bin: $PATH




to build the management library on the server side: (used to initialize gitosis)



Mode 1: (Client public key generation management library)



#sudo-H-u git gitosis-init < ~/id_rsa.pub



Initialized empty git repository in/home/git//repositories/gitosis-admin.git/reinitialized existing git repository in/ home/git/repositories/gitosis-admin.git/



Annotations:



1. The generated gitosis-admin is a git user access management library thatgitosis through this git repository to manage access to all git libraries.



2. By performing the initialization, the owner of the public key can modify the particular git repository used to configure the gitosis.



To modify upload permissions:



#chmod 755/home/git/repositories/gitosis-admin.git/hooks/post-update









Mode 2: (Server Public key generation management library)



$ su git # toggle down git user down



$ gitosis-init </tmp/id_rsa.pub # id_rsa.pub





Mode 3: Simple command Generation Management library:



Git init–bare test.git





5. Get and configure the Gitosis-admin management side (server side-----client side)



Server management libraries that can only be generated by the Clone server public key



Client managed libraries that can only be generated by the Clone client public key





#mkdir-P/git-repo/



#cd/git-repo/



#git clone [email protected] End Ip:gitosis-admin.git



#cd Gitosis-admin



#find.



./gitosis.conf



./keydir



./keydir/[email protected]



Annotations:



gitosis.confFiles used to set up control files for users, warehouses, and permissions



The Keydir directory is where all the public keys of the user with access rights are saved



./keydir/[email protected]:As mentioned before, the user has access rights
6. Create and set up a management project
#cd/git-repo/gitosis-admin
#ls keydir/
[email protected] ###### file name must be: xxx.pub
To add an item:
#vim gitosis.conf
[Gitosis]
[Group Gitosis-admin]
writable = Gitosis-admin
Members = [email protected] is the owner of the initialized gitosis public key and is the only person who can manage the gitosis admin project
[group Test] # Group Name
Members = [email protected] ා key user name
Writable = test? Warehouse name
#Git commit-a-M "User add"
#Git push
writable Readable and read- only readonly
Set different permissions for the same warehouse, such as:
[Group Test]
writable =test Warehouse Name
Members =[email protected]
[Grouptest2]
readonly= Test Warehouse Name
Members =[email protected]
If you encounter errors during Gitpush, "ddress 192.168.0.77 maps to Bogon, Butthis does not map back to the address-possible break-in attempt ", resolve to modify the/etc/hosts file, the IP address and host name corresponding to the relationship is written in.



7. Initial, increase and use Project Git-test (client)



#cd/git-repo



#mkdir Test



#cd Test





#touch README



#git Add.



#git commit-a-M "Init git-test"



#git remote Add origin [email protected]:git-test.git



#git Push Origin Master





Note: In the new project Git-test the first time to push data to the server, you need to set the server address as a remote warehouse, but you do not have to manually create the project to the server of the bare warehouse-gitosis will be automatically created when the first encounter push.






Description: If you are executing GIT push Origin master, the following error is indicated:



Error:srcrefspec Master does not match any.



Error:failedto push some refs to ' [email protected]:p ro2.git '



This is because the project is empty, and we create a new file in the project directory. By->add, commit, push, you can solve the






Ps:



$ Touch A.txt



$ git Add a.txt



In the directory where you added the files, enter Gitadd.



$ git commit-a-m ' Adda.txt '



$ git push



If you encounter a "Gitclone"



Error:cannotrun ssh:no such file or Directory-cygwin git "error, this means the computer does not have an SSH command installed. Installation method Please refer to: http://blog.haohtml.com/archives/13313





8. The client adds the other member's public key to the system: by adding the user's public key to the Keydir directory





1 " . generate key and public key



[[email protected] ~]$ ssh-keygen-t RSA
Generating public/private RSA key pair.
Enter file in which to save the key (/HOME/DEV1/.SSH/ID_RSA):
Created directory '/home/dev1/.ssh '.
Enter passphrase (empty for no passphrase):
Enter same Passphrase again:
Your identification has been saved In/home/dev1/.ssh/id_rsa.
Your public key has been saved in/home/dev1/.ssh/id_rsa.pub.
The key fingerprint is:
99:4C:E4:00:56:A9:A2:E2:68:20:8C:60:90:2E:B9:B8 [email protected]
The key ' s Randomart image is:
+--[RSA 2048]----+
| . Ooo.. |
|o. .+ |
|o. o |
|+o. o O |
| Bo. S |
| O. |
|*. |
| Eo |
|. |
+-----------------+



[[email protected]~]$ ls. ssh]
Id_rsa id_rsa.pub



2 " . upload the public key to the Gitserver of the gitosis-admin/keydir/ in the catalogue , The file name is the user name ( the file name must be the same as the client's user name, otherwise it cannot be used . ) how to handle without knowing the same name ? )
Note: I am here to test on the same machine, different machines can use the SCP command to implement the upload file, the main pub file uploaded to the Keydir directory (SCP ~/.ssh/id_rsa.pub [email protected]:/tmp/ sxf.pub)



cd/root/gitosis-admin/keydir/
Cp/home/dev1/.ssh/id_rsa.pub./dev1.pub



3 " . Create a new project that will Dev1 user Add in



cd/home/gitosis-admin/



Vigitosis.conf
[Group Project2]
writable = Project2
Members = Dev1



4 " . Save the changes and submit the changes to the git server on



git Add.
Git commit-a-m ' Add new user Dev1 '
git push



5 " . in the client test (user- dev1)
Create the Project Project2 directory (must be the same as the project name)



Mkdir/data/project2
Cd/data/project2
Git init
Touch Test.txt
git Add.



Gitconfig--global user.email "[Email protected]"
git config--global user.name "Your name"



Gitcommit-a-M ' Init project2 '
git remote add origin [email protected]:p Roject2.git
Git push Origin Master



Gitpull



You can see that it has been submitted successfully!



If the client is Linux, when executing git pull, it appears



Permissions0644 for '/root/.ssh/id_rsa ' is too open.



And so on the error shows, as long as the authority down to 0600 OK. In this case, it is generally a reason to place the public key in another place directly on the other client.



Input command



chmod 0600 ~/.ssh/id_rsa



Then execute the corresponding command. This will allow the key to log in.





9. Customer Password-free login:



The Dongsheng public key that is generated by the client is written in the/home/dongsheng/.ssh/authorized_keys file. (If you do not authorized_keys this file, create it yourself)




Note: Repositories on git have write access to git users and need to open RSA authentication in/etc/ssh/sshd_config, i.e.:


    1. 1.RSAAuthentication Yes
    2. 2.PubkeyAuthentication Yes
    3. 3.AuthorizedKeysFile. Ssh/authorized_keys




FAQ:



/home/git/repositories/gitosis-admin.git/hooks/post-update is an executable that has a property of 0755



1. Git operation requires a password
Reason
Public Secret not found
Solve
Upload id_rsa.pub to Keydir and change to ' gitosis account. Pub ' form, such as miao.pub. Extension. pub must not be omitted



2.error:gitosis.serve.main:repository Read access Denied






One by one , I readily add:



1 git init–bare test.git command to create a repository, if clone code, you can only use members within the GIT group



2 "gitosis-admin command to build the repository, if clone code, only git a user can use



CentOS Setup git full version


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.