Jun 7, 2018

How to reset password of Jenkins

Reset password of Jenkins

Prefer way, No securities were harmed

To reset it without disabling security if you're using matrix permissions (probably easily adaptable to other login methods):
  1. In config.xml, set disableSignup to false.
  2. Restart Jenkins.
  3. Go to the Jenkins web page and sign up with a new user.
  4. In config.xml, duplicate one of the <permission>hudson.model.Hudson.Administer:username</permission> lines and replace username with the new user.
  5. If it's a private server, set disableSignup back to true in config.xml.
  6. Restart Jenkins.
  7. Go to the Jenkins web page and log in as the new user.
  8. Reset the password of the original user.
  9. Log in as the original user.
Optional cleanup:
  1. Delete the new user.
  2. Delete the temporary <permission> line in config.xml.

Alternative way:

ssh to the server, disable authentication, set the password via the Jenkins Web UI, then enable authentication.

In configuration file of jenkins, for example: /var/lib/jenkins/config.xml

Change from:

Comment out the authorizationStrategy block
<!--authorizationStrategy class="hudson.security.GlobalMatrixAuthorizationStrategy">
restart jenkins, such as:
# service jenkins restart
After changing the password from web UI, you need to change back the configuration and restart jenkins service.