Huawei Cloud Yaoyun Server L instance evaluation | centos system building git private server


Preface

I have always wanted to build a private git server of my own, but I missed the manufacturer's event. This time I just happened to catch up with Huawei Cloud for evaluation, so here I will record the process of building a private git server as well as some problems and solutions encountered.
Whether we are working or studying, we must have some information of our own, and some content must be very important to us. If one day the computer breaks down and the files cannot be found, wouldn’t it be embarrassing, so Our files must have a backup. Of course, gitee and github can also store our files, but they have speed limits, so we still build our own git private server, which is more secure to use!


1. Huawei Cloud Yaoyun Server L instance rental

Here we choose to use Huawei's Yunyao Cloud Server to configure the git private server. We can just choose the corresponding configuration according to our own needs.
Insert image description here
Here you can choose the system you want. It is recommended that you choose the centos system.
Insert image description here

2. Install git on Huawei Cloud Yaoyun Server L instance

You can first check whether git is installed on the Huawei Cloud Yaoyun Server L instance.

git --version

You can see that it has been installed here. The version is 1.8.3.1. Insert image description here
Of course, if it is not installed, you can use the following command to install it.

yum install git

3. Huawei Cloud Yaoyun Server L instance git configuration

Create a new git account

adduser git
passwd 自己的密码

As shown below, it is configured.
Insert image description here
Switch to the git account and perform the following operations.

su - git

You can see that you have switched from root to git
Insert image description here
and are familiar with github. Everyone who is gitee knows that you need to configure your own public key on the page. You also need to configure it here. The purpose is to avoid entering the password when operating the git warehouse. Let’s configure it here
.

1. Create a file to store the public key

cd ~/
mkdir .ssh

2. Go to the .ssh file and create the mi file. This file stores our local public key.

cd ~/.ssh
touch mi

2. Set file permissions

The most important point is that you must set permissions for the mi file here, otherwise you will still have to enter the password.

chmod 700 /home/git/.ssh
chmod 600 /home/git/.ssh/mi

3. Configure local public key

Next, we go back to the local area, check our public key, and then configure it in the mi file. In our local area, there are generally two file paths, public key and private key. Generally, if there are no c:用户/用户名/.ssh文件中
Insert image description here
these two files, you can also create them using Just press Enter after the following command, and then you will see these two files in the above address.

ssh-keygen -t rsa

Then we will id_rsa.pubcopy it to the .ssh folder we just created and id_rsa.pubadd the contents to mithe file

cat id_rsa.pub >> mi

How to finally determine whether the key has been added? We go back to the local login git Huawei Cloud Yaoyun Server L instance, the local cmd window

ssh git@华为云云耀云服务器L实例ip

Here, the Huawei Cloud Yaoyun server L instance IP uses the public network IP. The following interface appears, and the configuration is successful.
Insert image description here

4. Huawei Cloud Yaoyun Server L instance deploys git warehouse

First switch to the git account

su - git

Create test.git folder

mkdir test.git

Initialize our git repository

git init --bare

4. git warehouse to local

Pull branches, please note that you cannot use absolute paths here, only relative paths.

git clone git@华为云云耀云服务器L实例id:/home/git/test.git

If the pull fails here, it may be caused by insufficient file permissions. You can use the following command to solve the problem.
Modify file permissions.

chmod -R 777 文件

In the following picture, we clone the Huawei Cloud Yaoyun Server L instance warehouse to the local area.
Insert image description here
Here we can verify it, create a TXT file, push it, and finally go to the Huawei Cloud Yaoyun Server L instance to view the log information, as shown in the figure: The Huawei Cloud Yaoyun Server L instance
Insert image description here
can see the record just submitted. That’s it. Your own git private server is now built!

Summarize

The above is all the content of building your own git private server through Huawei Cloud Yaoyun Server L instance. While there are still activities, everyone should hurry up and get some wool.

Guess you like

Origin blog.csdn.net/Lightismore/article/details/132773181