Ever forgotten your Jenkins admin password? Don't worry, regaining access is easier than you might think. This guide will walk you through resetting your password and securing your Jenkins server.

Generate a strong password

The first step is to create a strong, unique password for your Jenkins admin account. Here's how:

  • Use a password manager: Consider using a password manager to generate and store a complex password for Jenkins. This ensures security and avoids the risk of forgetting passwords.
  • Manual generation: If you prefer manual creation, follow these tips:
    • Use a combination of uppercase and lowercase letters, numbers, and symbols.
    • Aim for at least 12 characters in length.
    • Avoid using personal information or dictionary words.

Tools for Generating Secure Passwords:

  • jBCrypt: If you're familiar with jbcrypt, you can use the jBCrypt library to generate a secure password hash.
  • Online Bcrypt Hash Generators: Alternatively, you can use an online Bcrypt hash generator website. However, be cautious about entering your desired password on any website.

Update Jenkins configuration

Let's say I want to set my new password to test123. Generated output is $2a$06$asD3yrR8itMn6.5eS.QSS.AIeOkFLk9DBrp8kP3PvmNCIXK1.miYW.

Modify config.xml

sudo su nano /var/lib/jenkins/users/<your_jenkins_username>/config.xml

Replace passwordHash entry

<passwordHash>#jbcrypt:$2a$06$asD3yrR8itMn6.5eS.QSS.AIeOkFLk9DBrp8kP3PvmNCIXK1.miYW</passwordHash>

This will replace your current password with _test123_. Save file and reload jenkins.
- Now you can login to <your_jenkins_username> with password _test123_
- Go to _http://localhost:8080/<your_jenkins_username/>/configure_, and change password
Now you should be able to login to Jenkins with your new password.