Forgot your Jenkins login details? No worries! This guide walks you through how to reset Jenkins admin username and password quickly and securely. Get back to managing your builds and deployments in no time. For this demonstration, I’ve set up the latest version of Jenkins on Rocky Linux 9. While the specific commands might differ slightly, these steps are generally applicable for resetting Jenkins credentials on most Linux distributions.
Steps to Reset Jenkins Admin Username and Password
Regaining Control: Resetting Your Jenkins Username and Password
Before we dive in, remember this is a temporary security measure. We’ll definitely re-enable proper security after we get you back in. Now, let’s get started!
Step 1: Stopping the Jenkins Service
systemctl stop jenkins
Step 2: Editing the Configuration File
This file holds all the secret sauce for Jenkins, and you’ll need root or sudo access to edit it. It’s typically located at /var/lib/jenkins/config.xml.
Disabling Security (Temporarily)
Look for a setting called useSecurity. Change the value from “true” to “false”. This allows us temporary access without a password.
Login to Jenkins server using ssh or GUI console.
[root@rocky9 ~]# cd /var/lib/jenkins/ [root@rocky9 ~]# cat config.xml
Below screenshot of config.xml, how it looks before we update it.
As per above screenshot highlighted just change the value from “true” to “false”.
Earlier
<useSecurity>true</useSecurity>
Only change “true” to “false” and save the config.xml file.
<useSecurity>false</useSecurity>
Step 3: Start the Jenkins service
[root@rocky9 jenkins]# systemctl start jenkins
Step 4: Accessing Jenkins Without a Password
Now you should be able to access the Jenkins dashboard without entering a password.
Go to the Jenkins URL, In my case it is localhost:8080 and hit enter, You’ll see the Jenkins dashboard, but notice the missing login prompt. This is because we temporarily disabled security in the previous step.
Once logged in, navigate to “Manage Jenkins” and then “Configure Global Security” OR “Security”.
Here’s what you need to do:
- Set Security Realm to “Jenkins’ own user database.“
- Uncheck “Allow users to sign up.”
- Click “Save” to apply the changes.
Recovering Your Lost Username (If Applicable)
If you can’t remember your username, fret not! In the next step, you can check the list of users in the Jenkins interface.
Step 5: Resetting Your Forgotten Password
Now that security is back on, head over to “Users.”
As per above screenshot. I have only one user “sysadmin” in my Jenkins server. You will get a list of all usernames which are created in your Jenkins server. Click on the user for which you want to restart the password.
To Reset the Jenkins password. Click on the username and then “security”. Here, you can update your password to something new and secure.
Step 6: Restarting Jenkins
Finally, restart the Jenkins service one last time for the changes to take effect.
For systems using systemd (like Rocky Linux 9, Ubuntu, Debian (recent versions), Fedora, and many others):
systemctl restart jenkins
For older distributions that don’t use systemd (like CentOS 6 or 7):
service jenkins stop
service jenkins start
Step 7: Test Jenkins Login with Your New Credentials
It’s time to test your new login! Navigate to your Jenkins URL and enter your freshly created username and password. You should be good to go!
Congratulations!You’ve successfully reset your Jenkins credentials and secured your server. Now you can log in with your new credentials and get back to building and deploying like a pro.
Remember: Strong passwords are key! Use a combination of upper and lowercase letters, numbers, and symbols. Consider using a password manager for extra security. Regularly backing up your Jenkins configuration, including the config.xml file, is also a good practice.
FAQs:
Q. What if I don’t have admin access?
In this case, you’ll need to contact your system administrator to reset your credentials.
Q. Can I reset passwords for other users?
Yes, you can follow the same steps above to reset the password for any user in Jenkins, as long as you have administrative access.
Q. How can I improve Jenkins security?
- Use role-based access control (RBAC) to restrict user permissions.
- Enable two-factor authentication for added security.
- Keep your Jenkins software up to date with the latest security patches.
Q. What if I’m still having trouble?
If you’re following these steps and still facing issues, there might be an underlying problem with your Jenkins installation. Consult the official Jenkins documentation or seek help from online communities for troubleshooting assistance.
Q. Is there a way to reset my credentials without disabling security?
Unfortunately, no. Disabling security is a necessary step to regain access, but remember to re-enable it and configure it properly afterwards.
See also:
How to Install Jenkins on Ubuntu 22: A Comprehensive Guide
Top 20 Jenkins Best Practices for Efficient and Secure CI/CD Workflows
How To Install Jenkins on Rocky Linux 8 or CentOS 8
How to Install Jenkins on CentOS 7 or RHEL 7
Continuous Integration and Continuous Delivery
How to run Jenkins on Port 80 in Linux
How to Get Started with DevOps in 5 Easy Steps
10 Essential DevOps Tools for Your Business: Automate and Streamline Your Workflow