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:
After that, select Settings-Sign-up restrictions, click Expand on the right, as shown below:
In the pop-up page, cancel the Sign-up enabled option The previous tick, as shown below:
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:
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:
Next, we click Create Group at the bottom to complete the creation of the group, as shown below :
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:
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:
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:
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:
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:
Then in the pop-up page, we copy the public key copied before, as shown below:
Then click Add key to complete the addition, and the page after adding is as follows:
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