In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to install the Git version control server on the CentOS system". In the daily operation, I believe that many people have doubts about how to install the CentOS system to build the Git version control server. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the questions of "how to install the Git version control server on the CentOS system". Next, please follow the editor to study!
1.yum installs Git server
The code is as follows:
[root@git ~] # cd src/
[root@git src] # wget http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
[root@git src] # rpm-ivh epel-release-5-4.noarch.rpm
Preparing... # [100%]
Package epel-release-5-4.noarch is already installed
[root@git ~] # yum list
[root@git ~] # yum install-y git
two。 Create a git user to run the git service
The code is as follows:
[root@git ~] # adduser git
3. Create a client login certificate
Note: collect the public keys of all users who need to log in, which is their own generated id_rsa.pub file, and copy all the public keys into the / home/git/.ssh/authorized_keys file, one line at a time. Hey!
1)。 Commands for client to generate id_rsa.pub files
The code is as follows:
$ssh-keygen-t rsa
$cat .ssh / id_rsa.pub
Ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NwUHeNNi+PC6KlrcJrXXDmKxRMmgHIPp79sgX6zqfdSlmNj7rBPQeyEKS9Wg8yI6jd8aG2jsUx99Vjti2VK2vEXKkRHxwID7ri69gE71RfDtv6ekafnzLo14J8hAp0spMk+N3wEAQRYDmcYo1wmnm/jMBedGrHj4NJQ1vYy1hVtJasGMSzjcMrlz9qvaluWnQ5tQjKFQVVwKsRRRzs8qTvzVhLJt4NQ+CAN45tqfsRuf58Uba9QNK7/6xSUiIKXQiILz8PMGJ3MnlV+eN3wx2aeztdevxu9plggtG05SMmd8GNVzXrN1IaxXSvz0UwjQ2kygu7aCqO8AZWH49rouw== leo@LEO-PC
Note, you can enter all the way, copy the generated id_rsa.pub to the administrator and add it to the server for you. The next time you use git, you won't need to enter a user name and password.
2)。 View authorized_keys files on the server
The code is as follows:
[root@git ~] # cat / home/git/.ssh/authorized_keys
Ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAwMU4FKB6NRc3XSoIunWsdvVVuSoncbVb5Al6lB3ciswBVd++YmJFhqwkITNGccrO5sycROs9+Fbjgd6oBSzNuaBtCIbwNNsEyM/henTl2euI3XsnJQ/ITr6c/q0P3WoGl4E2QFQ2kZqs+1eDC0CgHcBrqvFv1Jr414sVYK9lfZwIF+jDdtaBOrSJuq1Agx9pGUFUEB4tQfkXxsWm/MvOmKAVvduKDE1eenUEL9zzyeELPcSXLe3NOoTjZhkX6EEXxQR1ZiZRFywLpfM4qopZ10to2KIUyVtzw6hx6V3cg7kn40lYVW0EAMATw9dVldwcRUI+kJzJSKUTKDVSwY3/+Q== root@CHENMINGQIAN
Ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAsmmJuR+KhRSpdSirCiL30RA8WbfgicY1z7itWVnKHJW6hTuJFhzruY59FilVjJR1hbQBluP9JnK3XPSK9PSg+bwiJ2iQRa39rXck35r+trVOLyNbPyfKVRfOemD8YuykMlyr5JeW8gZjsHEuLnJ8//RiCiYzd3RT/SSUQ4yawDoIIWkz3eUSL09xoCRZFBsAp+S/LD3vx2MN+FNOHwvqcE+yK3oRNIqjWwLoKE0e5TRnqNgrPQ95PJYB3XPUulzaeMwsWPZs7jIUMl/5yEqSgAkioa8SVMOsikYJG/erv99NNVgFmpCBIiWqKEGkNrIpYzLLHDSYQ4g5Gbci/RZ54Q== Administrator@WIN2003X323
Ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NwUHeNNi+PC6KlrcJrXXDmKxRMmgHIPp79sgX6zqfdSlmNj7rBPQeyEKS9Wg8yI6jd8aG2jsUx99Vjti2VK2vEXKkRHxwID7ri69gE71RfDtv6ekafnzLo14J8hAp0spMk+N3wEAQRYDmcYo1wmnm/jMBedGrHj4NJQ1vYy1hVtJasGMSzjcMrlz9qvaluWnQ5tQjKFQVVwKsRRRzs8qTvzVhLJt4NQ+CAN45tqfsRuf58Uba9QNK7/6xSUiIKXQiILz8PMGJ3MnlV+eN3wx2aeztdevxu9plggtG05SMmd8GNVzXrN1IaxXSvz0UwjQ2kygu7aCqO8AZWH49rouw== leo@LEO-PC
Description: I have three users logged in to the server, so I have three ssh-rsa here, you can take a look.
4. Initialize the Git repository
Note, first select a directory as the Git repository, here is / data/git/project.git.
The code is as follows:
[root@git ~] # cd / data/git/
[root@git git] # git init-- bare project.git
[root@git project.git] # ls
Branches config description HEAD hooks index info objects refs
Executing the above command Git creates a naked warehouse, which does not have a workspace. Because the Git warehouse on the server is purely for sharing, users are not allowed to log in directly to the server to change the workspace, and the Git warehouse on the server usually ends with .git. Then, change owner to git:
The code is as follows:
[root@git git] # chown-R git.git project.git
[root@git git] # ls-l
Total 4
The code is as follows:
Drwxr-xr-x 7 git git 4096 05-09 13:50 project.git
5. Disable shell login
Note that for security reasons, the git user created in step 2 is not allowed to log in to shell, which can be done by editing the / etc/passwd file. Find a line similar to the following:
The code is as follows:
[root@git ~] # cat / etc/passwd | grep git
Git:x:1001:1001:git version control:/home/git:/bin/bash
Change to:
The code is as follows:
[root@git ~] # vim / etc/passwd
Git:x:1001:1001:git version control:/home/git:/usr/bin/git-shell
In this way, git users can normally use git through ssh, but cannot log in to shell because the git-shell we specified for git users automatically logs out each time they log in.
6. Clone remote warehouse
Note: you can now clone the remote repository with the git clone command and run it on your respective computers:
Note: $git clone git@git.jjhh.com:/data/git/project.git, where git user name, git.jjhh.com server, / data/git/prgject.git is the warehouse path. All right, this is the end of the server. Let's install the client.
7. Create SSH Key
First of all, under the user's home directory, see if there is a .ssh directory, and if so, see if there are id_rsa and id_rsa.pub files in this directory. If you already have one, you can skip to the next step. If not, open Shell (open Git Bash under Windows) and create a SSH Key:
The code is as follows:
$ssh-keygen-t rsa-C "youremail@example.com"
You need to change your email address to your own email address, and then enter all the way, using the default value, and since this Key is not used for military purposes, there is no need to set a password.
If all goes well, you can find the .ssh directory in the user's home directory, which contains two files, id_rsa and id_rsa.pub, which are the key pairs of SSH Key. Id_rsa is the private key and cannot be leaked out. Id_rsa.pub is the public key and you can safely tell anyone.
8.Git server opens RSA authentication
Then you can add your public key to the Git server to verify your information. On the Git server, you first need to turn on the RSA authentication in / etc/ssh/sshd_config, that is:
1.RSAAuthentication yes
2.PubkeyAuthentication yes
3.AuthorizedKeysFile .ssh / authorized_keys
Here we can see that the public key is stored in the .ssh / authorized_keys file. So we create the .ssh directory under / home/git, then create the authorized_keys file, and import the public key we just generated.
Then when you clone again, or later when you push, you don't need to enter the password:
The code is as follows:
Zhu@XXX/E/testgit/8.34
$git clone git@192.168.8.34:/data/git/learngit.git
Cloning into 'learngit'...
Warning: You appear to have cloned an empty repository.
Checking connectivity... Done.
At this point, the study on "how to install a Git version control server on a CentOS system" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.