Hi team,

I recently installed a Jenkins machine and forgot to create a “first admin user”, but I also forgot the password to log in with default admin user (I guess default password was admin but it doesn’t matter now because I figured out how to log in without it temporarily in order to recover it 🙂 )
Here is what you will see below

Jenkins first installation and admin password location:

During my previous blog regarding Jenkins installation we saw that the first user we have to connect on Jenkins GUI has its password set under this path ( regarding Linux ):

/var/lib/jenkins/secrets/initialAdminPassword

for Windows it’s located under this path:

 C:\Program Files\Jenkins\jenkins.err.log
JENKINS_HOME\secrets>initialAdminPassword

Once this password in your possession,you can connect for the first time to your Jenkins GUI and then choose if you want to configure an administrator and then add new users.
In my case I was not able to get back the password as I have updated it.

Connect without authentication

  • A way to allow you connection to your Jenkins master is to update its configuration file:
/var/lib/jenkins/config.xml


You must update the line regarding “use Security” from true to false

Restarting Jenkins after update

  • After update you have to restart Jenkins then connect on your web instance

[root@serveurctmv900 jenkins]# sudo service jenkins restart

Connect to Jenkins user interface and and create an emergency user

  • Go to security configuration part in Jenkins dashboard and check allow anyone to do anything

  • Then you can go to “create users” part and create user with admin rights

  • Define your user and password

  • You see now that a new user is here  try to connect to Jenkins ,then you can also update admin password if you want


  • You are now connected with your new user ( you can give him right level needed , for this example it will be able to do everything )

  • Update your admin password if needed

Go to /user/admin/configure ( manage user – admin- configure )

  • Don’t forget to put back your security settings

Conclusion:

Now you are able to update the admin password and/or use another  admin user!Don’t forget security matters and be sure that admin password isn’t used in another place or in some builds ( which is NOT best practice )
See you next time for another blog regarding Jenkins and Ansible integration 😉