Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Jenkins - Admin Reset Password

Steps

It can be really annoying when you're locked and and forgotten your username/password, with no option to perform a password reset.

Generate Password Hash

The first thing we need to do is create a bcrypt hash to represent our new password:

Option 1 - If you have the PHP CLI installed, you can execute the following line in your terminal:

php -r "echo '#jbcrypt:' . password_hash('myPasswordHere',  PASSWORD_BCRYPT) . PHP_EOL;"

Option 2 - Use this online tool and fill in your password to generate a bcrypt hash before prefixing it with: #jbcrypt:.

Replace Config File

Navigte to your users directory and list them

cd $HOME/jenkins/users
ls

Then edit the configuration file of the user you wish to set the password for. E.g.

vim programster_7682627586314307599/config.xml

Update the password hash to what you generated.

<hudson.security.HudsonPrivateSecurityRealm_-Details>
  <passwordHash>#jbcrypt:$2a$10$wR1qxmji.JkSfg87D5cvu.PXXXXXXn2eQXXXXXX2KJAdLXXXXXXXX</passwordHash>
</hudson.security.HudsonPrivateSecurityRealm_-Details>

Restart Jenkins

Then restart Jenkins and you are good to go. This will either be:

docker-compose down
docker-compose up

...or:

sudo service jenkins restart

Login

You should now be able to login using your user's username, and the password you just generated a hash for.

References

Last updated: 16th April 2021
First published: 16th April 2021

This blog is created by Stuart Page

I'm a freelance web developer and technology consultant based in Surrey, UK, with over 10 years experience in web development, DevOps, Linux Administration, and IT solutions.

Need support with your infrastructure or web services?

Get in touch