Jenkins doesn’t provide straight forward way to rest Admin account password. Once you missed the admin account passwrod, you need to remote current admin account and create a new one.
This tutorial will help you to reset Jenkins admin users password by creating a new account.
Steps to Reset Jenkins Admin Password
Follow the below steps to recover admin account access of Jenkins portal.
- Disable Current Security – First of all, login to your Jenkins server and edit Jenkins configuration file in your favorite text editor
Edit /var/lib/jenkins/config.xml file:
sudo vi /var/lib/jenkins/config.xml
Disable the security by changing userSecurity tag value to “false”.
Save your file and close it. The vim users press ESC + :wq! to save file.
- Apply Changes – Restart Jenkins service to apply the changes.
sudo systemctl restart jenkins
After restarting make sure the jenkins service is running with
sudo systemctl status jenkinscommand.
- Access Jenkins as Anonymous User – Again access Jenkins in web browser, It will redirect you to dashboard without prompting for authentication. You will be logged in a anonymous user to the Jenkins.
Next, Go to people tag
- Delete Admin Account – Select the Admin user account to delete. Then click the delete buttion to detele selected account
Click Yes to confirm the account delete.
- Enable Security Again – Now once you deleted old admin user. To reset all security options, go to “ Jenkins -> Manage Jenkins “ option in left hand side option lists.
Go to “Configure Global Security” option
You will see all option as bellow, do all below mentioned changes on this page
- Enable “Enable Security’ option.
- In Security Realm option select “Jenkins own database”
- Make sure to uncheck “Allow users to sign up” option under the “Jenkins own database” option.
- Save Changes – Save all changes made above.
- Create Admin Account – You will be redirected to “Create First Admin User”. Input all required details to create a new Admin account.
- Login with New Admin User – Now, you can access your Jenkins dashboard using the newly created Admin account.
- All Done