Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to add SSH global credentials for Jenkins

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Most people do not understand the knowledge points of this article "how to add SSH global credentials for Jenkins", so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to add SSH global credentials for Jenkins" article.

What is a credential 1. Brief introduction to credentials

There are many third-party websites and applications that can interact with Jenkins, such as the code repository GitHub.

System administrators for such applications can configure credentials in the application to be used exclusively by Jenkins. This is usually done by applying access control to these credentials to "lock down the application functional areas available to the Jenkins." Once the Jenkins administrator adds / configures these credentials in Jenkins, the Jenkins project can use the credentials to interact with these third-party applications.

The credentials saved in Jenkins can be used to:

Applies anywhere in the Jenkins (that is, the global certificate).

A specific Jenkins project.

Specific Jenkins users.

2. Credential classification

Jenkins can save the following credentials:

Secret text: for example, API Token (for example, GitHub's personal access token).

Username with password: refers to the user name and password of the login GitHub, which can be treated as a separate component or as a colon splitting string in username:password format.

Secret file: it's actually a secret content in a file.

SSH Username with private key: that is, the SSH user name using the private key. This is an SSH key pair. The public key is configured on top of the GitHub, where the private key is added.

Certificate: a certificate. An PKCS#12 certificate file and an optional password.

Docker Host Certificate Authentication: that is, Docker host certificate authentication credentials.

The classification of these credentials can be seen in the global credentials:

3. Credential security

To ensure security, credentials configured in Jenkins are encrypted in the Jenkins primary instance (encrypted through the ID of the Jenkins instance) and can only be processed in the Pipeline project through their credential ID.

This minimizes the possibility of exposing the actual certificate itself to Jenkins users and limits the ability to copy functional certificates from one Jenkins instance to another Jenkins instance.

Second, add credentials

Let's take adding SSH Username with private key as an example to show how to add a Jenkins credential.

As mentioned above, SSH credentials require a pair of private keys, so we need to generate SSH Key first.

Use the following command to generate SSH Key:

$ssh-keygen-t rsa-C "your_email@youremail.com"

As shown in the following figure:

All options are default and can be generated by pressing enter all the time. After generation, the file is generated under the .ssh folder, as shown in the following figure:

A total of two files are generated:

Id_rsa . This is the private key file.

Id_rsa.pub . This is a public key file and needs to be configured on GitHub.

Log in to GitHub and select "Settings" under the account:

Then select "SSH and GPG keys":

Then click "New SSH key" and copy the contents of the generated id_rsa.pub file into it:

This completes the addition of SSH key.

When Jenkins pulls the git project code, if the "certificate credential Credentials" is not configured or the configuration is incorrect, the error message shown in the following figure will appear:

At this point, you need to add the certificate credential Credentials. There are two ways to add the certificate credential.

1. Add when creating

Click "Add" after Credentials, and select "Jenkins", as shown in the following figure:

Then select SSH Username with private key, as shown in the following figure:

Select Private Key, as shown in the following figure:

Copy the private key generated above and give Username a name.

Finally, click the "add" button to finish adding SSH credentials.

Note: when copying the private key here, be sure to copy everything in the generated private key file.

Select the credential you just added when you select the credential, and there will be no error:

2. Add to the voucher

We can also add to the credential

Again, select "SSH Username with private key", as shown in the following figure:

Then the following steps are the same as just now, just enter the generated private key. This configures the SSH credentials.

The above is about the content of this article on "how to add SSH global credentials for Jenkins". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more related knowledge, please pay attention to the industry information channel.

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report