How to reset the Jenkins admin password

We recently assisted a client who had lost their administrator password for Jenkins. Luckily, the solution is rather straightforward - as long as you have root access to the server.

While Jenkins security could be disabled altogether with a simple configuration file switch, the easiest workaround is just resetting the password hash to a known value. This will ensure that all other security settings stay intact.

Please note that these instructions require you to have SSH access into the Jenkins server.

The tl;dr

Here’s a 1-liner to reset the admin password to ‘releaseworks’ on most systems:

sudo 'sed -i "" /var/lib/jenkins/users/admin*/config.xml && service jenkins restart'

The longer story

$ sudo su jenkins
# cd /var/lib/jenkins/users
# ls
admin_94129024

#