Jenkins - Admin Reset Password
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:
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.
Update the password hash to what you generated.
<hudson.security.HudsonPrivateSecurityRealm_-Details> <passwordHash>#jbcrypt:$2a$10$wR1qxmji.JkSfg87D5cvu.PXXXXXXn2eQXXXXXX2KJAdLXXXXXXXX</passwordHash> </hudson.security.HudsonPrivateSecurityRealm_-Details>
Then restart Jenkins and you are good to go. This will either be:
docker-compose down docker-compose up
sudo service jenkins restart
You should now be able to login using your user's username, and the password you just generated a hash for.
First published: 16th April 2021