Detailed explanation of CICD (9) - simple use of gitlab

Today, I will continue to introduce the relevant knowledge of Linux operation and maintenance. The main content of this article is the simple use of Gitlab.

1. Gitlab turns off automatic registration

In the production environment of the enterprise, the project leader is generally responsible for creating users and assigning permissions. Generally, employees are prohibited from registering users without permission to prevent security risks to the project development work. To avoid employee auto-registration, we generally disable Gitlab's auto-registration feature. On the main menu of Gitlab, select Menu-Admin, as shown below:
insert image description here
After that, select Settings-Sign-up restrictions, click Expand on the right, as shown below:
insert image description here
In the pop-up page, cancel the Sign-up enabled option The previous tick, as shown below:

insert image description here
In this way, after clicking Save below, we can make our configuration take effect. In this way, when you log in, automatic registration cannot be achieved.

2. Create a project in Gitlab

After completing the above configuration, we next need to create a project on Gitlab. Since the creation of a new project must depend on a group, we create a group before creating a project.
After entering the Gitlab main page, click the Groups option in the Overview, then click New group on the right, and select to create a new group, as shown below:
insert image description here
Enter the name and description of the group, and the URL of the group will appear automatically with the input of the group name. , in the group permissions, we select Private, and cancel the request to allow user access below. After the configuration is completed, it is as follows:
insert image description here
Next, we click Create Group at the bottom to complete the creation of the group, as shown below :
insert image description here
Next, let's create the project. The process of creating a project is similar to that of a group. It is to enter the project name, select the name of the group, project description and permissions, etc. The configured project is as follows:

insert image description here
After the configuration is complete, click "commit changes" below to create the project.
After creating the project, Gitlab will automatically create a README.md file, which we can edit online, as shown below:
insert image description here

insert image description here

Three, Gitlab login password-free authentication

Finally, let's explain Gitlab's password-free login authentication. After the configuration is complete, our Gitlab can automatically execute Git commands without logging in. This step is necessary for script writing and the use of other projects (such as Jenkins).
First, execute the command on the device you want to authenticate:

ssh-keygen

The result is as follows:
insert image description here
After completing the above configuration, you can generate the public and private key pair of the device and execute the command:

cat /root/.ssh/id_rsa_pub

You can view the public key of this device, as shown below:
insert image description here
We copy the public key, then we open Gitlab, click the user icon in the upper right corner, select Edit Profile in the pop-up selection box, and then click SSH Keys on the left, As shown below:
insert image description here
Then in the pop-up page, we copy the public key copied before, as shown below:
insert image description here
Then click Add key to complete the addition, and the page after adding is as follows:
insert image description here
Note: In this actual combat , when we execute the ssh-keygen command on the authentication device, pay attention to the hostname of the device. It is best to change the hostname of the device first to prevent problems in the end.
Originality is not easy, please indicate the source for reprinting: https://blog.csdn.net/weixin_40228200

Guess you like

Origin blog.csdn.net/weixin_40228200/article/details/123883229