[Linux | Jenkins] How to reset a Jenkins user password
by Riley MacDonald, December 27, 2018

Having not used my Jenkins instance for a few months I forgot my users password. My Jenkins ver. 2.138.2 has no “reset password” UI to accomplish this, it needs to be reset from the server. This post describes how to reset a Jenkins password on a headless linux server. This post assumes you have installed Jenkins using the default path and settings.

SSH into the server and change directory to /var/lib/jenkins/users/[your_username]/. Create a backup of the existing config.xml file.

# Switch directory to the jenkins install 
cd /var/lib/jenkins/users/[your_username]
 
# Create a backup of existing config file
cp config.xml config_bak.xml

Generate a new password hash using sha256:

# Generate a new hash (username is the username, password is the password)
echo -n 'password{username}' | sha256sum
 
5d195991675200c86815c345b16d7d1aa6a77dabafd0b7941499bd78946004f9

Copy the hash. Edit the config.xml file and modify the line containing passwordHash to contain the username and the hash:

<passwordHash>username:5d195991675200c86815c345b16d7d1aa6a77dabafd0b7941499bd78946004f9</passwordHash>

Restart Jenkins:

sudo systemctl restart jenkins.service

You should now be able to log in using the newly generated password.

Open the comment form

Leave a comment:

Comments will be reviewed before they are posted.

User Comments:

Saran on 2020-12-05 15:56:23 said:
can we decrypt the hashed passwords?? well I think it is impossible but I have a task regarding this decryption of user password

BJ. G. on 2020-08-12 20:21:47 said:
Huge thanks for these very clear and concise steps. One suggestion: Provide at least a Warning (if not workaround) about the clear text password possibly being saved to one's .history file, when echo'ing it into the 'sha256sum' utility. Thanks again.