Sunday 10 September 2023

Jenkin : Forgot Admin password

 Prerequisites:

*.A super user( root) or any user with SUDO privileges.

*.vim/ vi/ text editor to edit the configuration files.


Steps to recover forgotten password in Jenkins

1.Now, copy and take the backup of configuration file of Jenkins and save it.

# cp -v /var/lib/jenkins/config.xml ./config.xml_0923_passwordreset


Step 2: Open the /var/lib/jenkins/config.xml configuration file and turn off the protection.


# vi /var/lib/jenkins/config.xml 

And now, find the <useSecurity> tag and change the value from true to false.

  <useSecurity>true</useSecurity>   ####Put the value is false

  

Step 3: After making the above changes, restart the Jenkins services. After restarting the services, make sure the status of Jenkins is running and enabled


[root@jenkins]# systemctl stop jenkins.service

[root@jenkins]# systemctl start jenkins.service


Step 4: Now, open your browser, and hit try to open the jenkins. You will now not be asked to enter the credentials.

After this, navigate to "Manage Jenkins" button from the option from the left side menu and click on "Configure Global Security" just as shown below.



Step 5: Now, navigate to Security Realm, and select the "Jenkins' own user database" from the dropdown menu. and click on save button from the button and click on Dashboard.



Step 6: Now, after clicking on "Dashboard", go to "People" menu, as shown below. And, select the username of which you want to change the password.






Step 7: Now, go to your server and either replace the existing configuration file with that of you had make in step 2 or replace from "false" to "true", that you had make in step 3.


mv ./config.xml_0923_passwordreset /var/lib/jenkins/config.xml

or

vi /var/lib/jenkins/config.xml


Step 8: Now just restart the jenkins service and test your login to your Jenkins using browser.


[root@jenkins]# systemctl stop jenkins.service

[root@jenkins]# systemctl start jenkins.service


And this is how you will recover the forgotten password of admin user in Jenkins.


No comments: