How do I login to Jenkins when I locked myself out?

Issue

  • When managing user permissions, a user might set a permission wrong and lose access when using their main administrator account. Regaining access can be done in a few steps.
  • global security needs to be changed, unable to login as administrator

Environment

Resolution

1) Stop Jenkins

2) Edit the config.xml file in the JENKINS_HOME folder and locate this line:

`<useSecurity>true</useSecurity>`

Set the value to `false`

3) Start Jenkins

4) If you don’t know your admin password when using Jenkins’ own user database for your Security Realm, go to:

```
JENKINS_URL/user/admin/configure
```

to set the new `admin` password.

5) Now go to Manage Jenkins -> Configure Global Security and choose your Security Realm and Authorization settings to re-enable security.

Note: an alternative to step 2 is to restore a known good configuration of JENKINS_HOME/config.xml from a backup that was taken immediately before the Configure Global Security changes were done that caused the issue. We recommmend you do a diff of the current content of JENKINS_HOME/config.xml and the version from the backup before you replace it, to ensure you understand what you are reverting.

Have more questions?

2 Comments

  • 0
    Avatar
    Namrata Shilpi

    I'm using LDAP plugin for login. Everytime I restart my Jenkins Master I need to 'Edit the config.xml file in the JENKINS_HOME' and reconfigure my LDAP settings from scratch. Is there a way to avoid this cumbersome process?

    Edited by Namrata Shilpi
  • 0
    Avatar
    Denys Digtiar

    Hi Namrata,

    This should not be necessary if Jenkins is operating normally. If you are a CloudBees customer, feel free to raise a support ticket so that we can help you troubleshoot the issue.

Please sign in to leave a comment.