In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
In this article, I will introduce how to build your own git server on a fully naked Ali cloud host. Each step is described in detail, as follows:
1. Install git
First install git, generally speaking, the server now has a built-in git installation package, we only need to execute a simple installation command to install. For example:
$yum install git # centos$ apt-get install git # ubuntu
The above is directly using root login server to operate, but also for the convenience of demonstration.
Git is different from mysql. When mysql is installed, we have to install mysql-server, that is, mysql server. Git is distributed. Every computer that installs git is both a client and a server. Git and git can communicate with each other. In fact, our so-called git server is not essentially different from our own computers. However, we all adopt a centralized management approach in order to manage the project more effectively, so we create a "git server" as the final terminal for everyone else to submit the code.
two。 Create git users and permissions
Of course, we are not allowed to use root directly for communication interaction, so we create a git user as the user who submits the code in the future.
$adduser git
After executing this command, you find that there is an extra git directory in the / home directory. In theory, you now have this git user in your system, and the home directory is in / home/git. However, we do not want this user to connect to the server through ssh, so we want to prohibit this user from using ssh connection to operate. We deal with this by editing a permissions file:
$vi / etc/passwd
Find something similar to
Git:x:1001:1001:,:/home/git:/bin/bash
In a line like this, you see the / bin/bash at the end, which is the permission to allow the ssh connection operation. Let's change it to / user/bin/git-shell, and the result is as follows:
Git:x:1001:1001:,:/home/git:/usr/bin/git-shell
Handled in this way, git will not be able to connect to ssh (in fact, it can, but it will flicker).
We also have to assign a password to git to execute:
$passwd git 123456 (your password)
This password is used when you submit the code later.
3. Public key
This is a special step in git. When communicating, the client and the server need a certificate for verification. The method of operation is simple, first generate your own public key on your own computer (ubuntu):
$cd ~ $ssh-keygen-t rsa
Then you have a public key on your own computer, but where is it? Under the .ssh directory,. The first folder is hidden, but you can cd it.
$cd .ssh $vi id_rsa.pub
So you can see your public key and copy everything down. Next, let's go back to the server.
$cd / home/git/$ mkdir .ssh $cd .ssh $vi authorized_keys
If it is bare metal, there should be no .ssh directory under the / home/git directory on the server, so we create it ourselves, open (automatically create) authorized_keys, paste in the public key we just copied, ok, save and exit.
Certificates are used mainly to submit code without a password.
4. Initialize a git repository
I'm used to throwing this kind of stuff under / var, so let's create a git directory under / var
$cd / var$ mkdir git$ chown-R git:git git$chmod 777 git$ cd git
Next, we initialize a warehouse with the git command:
$git init-bare arepoforyourproject.git
After initialization, the empty warehouse is OK.
Here is a detail, that is, the .git directory must have read and write permissions, because when we are in push, we use git users to push to the server, there will be a writing process, if not given writeable permissions, push will fail.
5. Try cloning.
Go back to your local computer, and we'll clone to see if the warehouse can be used:
$git clone git@10.0.0.121:/var/git/arepoforyourproject.git
Then you will be prompted to enter your git password, enter it, and then prompt you to clone a blank version library. This means that the server is already OK.
6. Multi-user and rights management
If the team is small, it is possible to collect everyone's public key and put it in the / home/git/.ssh/authorized_keys file on the server. If there are hundreds of people on the team, you can't play like this, and you can use Gitosis to manage the public key.
The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.
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.