How To Reset Jenkins Security Settings From The Command Line ? (original) (raw)

Last Updated : 20 Feb, 2024

This article guides you through in resetting Jenkins security settings from the command line. It is crucial to understand the associated risks and prioritize alternative solutions whenever possible. We'll dive into the completely disabling security (a highly discouraged option. Remember, security is essential so perform the configurations carefully and only use this method as a last resort.

What is Jenkins?

Jenkins is an automation hosting web server built on top of Java. It is used for continuous integration and continuous deployment. It comes with supporting a lot of plugins that help in integrating many tools and services. It helps in building pipelines and functions automatically when the monitoring is noticed it triggers the actions as per the request.

Step-By-Step Implementation Of Reseting Jenkins Security Settings From CLI

Firstly let's set the Jenkins on top of AWS using Amazon Linux As Image and Then Start the Jenkins server. The following are step-by-step implementations of Jenkins setup.

Step 1: Navigate to EC2 Dashboard

1-AWS-Sign-Console

3-Name-And-AMI

Step 2: Configuring Security Groups

4-Configuring-Security-Credentials

5-Navigatig-To-Inbound-Rules

6-Configuring-Inbound-rules

Step 3: Connect To EC2 Console

For the CLI mode of interaction we are using EC2 Console other prefered alternative way will be downloading ssh key and connecting from local command line.

7-Connecting-to-EC2-Console

Step 4: Update The System

For having more access and powers switch to root or else you run same commands with using sudo initially.

yum update -y

8-Updating-the-System

Step 5: Add The Jenkins Repository

wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat/jenkins.repo

rpm --import https://pkg.jenkins.io/redhat/jenkins.io-2023.key

Step 6: Install The Java

sudo yum install java-17* -y

Step 7: Install The Jenkins

Install the Jenkins after successful installation of Java software or else it raises error in the jenkins setup. Jenkins is build on top of java.

yum install jenkins

9-Jenkins-Installation

Step 8: Verify The Jenkins And Java Installation

java --version
Jenkins --version

10-Verifying-Java-And-Jenkins

Step 9: Start The Jenkins Server

Start the jenkins server with the following command:

systemctl start jenkins

or

systemctl enable jenkins --now

11-Starting-Jenkins-Server

12-Launching-Jenkins-Web-Server

Resetting The Jenkins Security Settings From the Command line

Step 10: Stop The Jenkins Server

systemctl stop jenkins

13-Stoping-The-Jenkins-Server

Step 11: Configuring The Jenkins File

vim /var/lib/jenkins/config.xml

14-Jenkins-Configiration-file

Step 12: Disabling the security Section Of Jekins

1708150799671 /tmp 494424064 497872896 hudson.node_monitors.TemporarySpaceMonitor 1073741824 2147483648 2.445 2 NORMAL true true true false false ${JENKINS_HOME}/workspace/${ITEM_FULL_NAME} ${ITEM_ROOTDIR}/builds [root@ip-172-31-7-48 ~]# vim /var/lib/jenkins/config.xml [root@ip-172-31-7-48 ~]# vim /var/lib/jenkins/config.xml [root@ip-172-31-7-48 ~]# cat /var/lib/jenkins/config.xml 1708150799671 /tmp 494424064 497872896 hudson.node_monitors.TemporarySpaceMonitor 1073741824 2147483648 2.445 2 NORMAL false true true false false ${JENKINS_HOME}/workspace/${ITEM_FULL_NAME} ${ITEM_ROOTDIR}/builds 0 all false false all -1 false false

The below screenshots the practical configuring to false for disabiling the security.

15-Disabiling-The-Jenkins-Security

Step 4: Restart The Jekins Server

systemctl restart jenkins

After restarting the jenkins check the status of jenkins, If it is running then the jenkins configuration is working fine and security of jenkins is disabled.

16-Restarting-Jenkins

Conclusion

Resetting Jenkins security settings from the command line should be a last resort due to the inherent security risks. Always prioritize alternative solutions and exercise extreme caution when using these methods. Remember, securing your Jenkins server is crucial for maintaining the integrity and reliability of your CI/CD pipeline.