How to recover Jenkins admin login

If the security configurations for Jenkins is not proper, there may be a chance to get admin user locked out.

This article explains the steps to recover Jenkins admin login by disabling the security authorization.

Step1: Login to the Jenkins instance via ssh.

Step2: Stop Jenkins service.

#systemctl stop jenkins

Step3: Change the location to Jenkins home directory.

#cd /var/lib/jenkins

Step4: Open the Jenkins configuration file.

#vi config.xml

Step5: Update the following line and save.

<useSecurity>true</useSecurity>

Step6: Remove the elements authorizationStrategy and securityRealm from the same file and save.

Step7: Start Jenkins service.

#systemctl start jenkins

Step8: Now we can login to the Jenkins web console without any authorization and reset the admin user password as well as complete the security configurations.

That's all…