Jenkins: Reset Admin Password

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 →

Reset Jenkins Admin Password

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:

  1. Navigate to "Manage Jenkins" -> "Security" -> "Configure Global Security" -> "Authentication"
  2. Select the "Security Realm" (e.g. "Jenkins’ own user database") and click on "Save"
  3. Go to "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

6 Replies to “Jenkins: Reset Admin Password”

  1. thanks a lot !!

  2. It worked!!! Thanks.

  3. This appears to no longer work. After setting to false Jenkins will no longer start.

    1. First stop the Jenkins from the services and then set the to false and then restart the Jenkins service. It should work.

  4. Hi AVATAR42
    It worked for me in Jenkins 2.319.1
    Thanks to “admin”

  5. Thanks. This worked for me on Jenkins v2.346 !

Leave a Reply