Reset Jenkins Default User Password
Forgot Password Jenkins
2 min read
One of the most tedious tasks is to find your default Jenkins password after you have successfully signed in and you forgot to reset the password provided by Jenkins. Usually, Jenkins provides an initial password after the first set up and you are expected to reset this password almost immediately, as Jenkins server has no provision for resetting passwords.
In this article, I am going to share with you one of the challenges I faced while learning Jenkins and how I was able to resolve it.
I had Jenkins installed on a Linux Virtual Machine, and the next day, I couldn’t log in as I was unable to key in the current username and password. At this point, you might want to spin another VM and set up a new Jenkins Server but No, we can get this fixed right away.
On setting up Jenkins server, the initial password was used which is located at /var/lib/jenkins/secrets/initialAdminPassword but at this point, this file is nowhere to be found at the same location as seen in the image below, we need to find another way to save the day.
Lets Proceed to Fix this:
Locate your home directory where Jenkins is installed on your machine Linux Home Directory /var/lib/jenkins Windows Home Directory -- C:\Users\.jenkins
Locate the config.xml file in /var/lib/jenkins directory
Sudo vi config.xml
Locate the line where usesecurity is defined as true and set this to false as shown below
You may want to backup config.xml before editing.
At this point, you now have access to your Jenkins servers. Yeah, it's a relief! Launch your Jenkins server now and Waoohh access is granted without any authentication. However, we won't leave our CI/CD server open to anonymous access. We will proceed to set up security again.
Configure Security for Jenkins
- On your Jenkins server, navigate to manage Jenkins, Configure global security >> Jenkins own user database >Apply and Save
Configure >> manage users >> edit your user password and you can add more users
Restart Jenkins and log in with your new user password
Remember to change back default setting in your config.xml file.
Did you learn something new?
Like and share your thoughts with me in the comment section.