Posted on September 8, 2020by admin
If you have forgotten the Jenkins admin password and can’t log in to a Jenkins user interface (UI) as administrator, you can connect to a Jenkins server via SSH and reset the Jenkins admin password.
The simplest solution is to completely disable security in /var/lib/jenkins/config.xml
file, access the Jenkins UI omitting authentication and rest the Jenkins admin password.
Cool Tip: Jenkins Username & Password by Default! Read more →
Make a backup copy of a Jenkins config file (this step is important as after resetting the Jenkins admin password we would need to restore the previous settings):
$ cp /var/lib/jenkins/config.xml /var/lib/jenkins/config.xml.back
Open the config file /var/lib/jenkins/config.xml
and disable the security:
<useSecurity>false</useSecurity>
Restart the Jenkins service:
$ systemctl restart jenkins
Go to the Jenkins UI (you won’t be asked for any credentials this time) and reset the admin password:
"Manage Jenkins"
-> "Security"
-> "Configure Global Security"
-> "Authentication"
"Security Realm"
(e.g. "Jenkins’ own user database"
) and click on "Save"
"People"
-> Click on a username for which you want to change the password (e.g. admin
) -> "Configure"
-> Enter a new password in the "Password"
and "Confirm password"
fields and click on "Save"
Once the admin password is reset, restore the previous /var/lib/jenkins/config.xml
file and restart Jenkins:
$ mv /var/lib/jenkins/config.xml.back /var/lib/jenkins/config.xml $ systemctl restart jenkins
Last Updated: 05/01/2023 11:54
A total of 0 / 0 users found this article useful.