Jenkins
Devops

How to Reset Jenkins Admin User Password

We have seen in a previous article how to install and configure Jenkins. In this article we will see how to reset Jenkins admin password allowing us to connect to the web interface.

Steps to Reset Jenkins Admin Password

If you forgot or lost Jenkins admin password to connect to Jenkins web interface, don’t worry, just follow the steps bellow :

Step 1: Disable Current Security 

first of all, edit the file login to your Jenkins server and edit the Jenkins configuration file :

[root@jenkins ~]# vi /var/lib/jenkins/config.xml

Locate the <useSecurity>true</useSecurity> then change the value to false and save the file.

<numExecutors>2</numExecutors>
  <mode>NORMAL</mode>
  <useSecurity>false</useSecurity>
  <authorizationStrategy class="hudson.security.FullControlOnceLoggedInAuthorizationStrategy">

Here we disabled the security.

Step2: Restart Jenkins Server

Restart the Jenkins server and wait for it to fully load.

[root@jenkins ~]# systemctl restart jenkins

Make sure the Jenkins service is running :

[root@jenkins ~]# systemctl status jenkins
● jenkins.service - Jenkins Continuous Integration Server
   Loaded: loaded (/usr/lib/systemd/system/jenkins.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2023-05-08 23:25:56 +01; 1min 18s ago
 Main PID: 1927 (java)
   CGroup: /system.slice/jenkins.service
           └─1927 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/java/jenkins.war --webroot=%C/jenkins/war --httpPort=8080

Step3: Delete the user admin

Now access to the Jenkins web page, this time you can access to the dashboard without prompting for authentication.

Go to the `People` option

Select the admin user account and delete it :

Step 4: Enable Jenkins Security

Now we have to reset all security options. Click on Manage Jenkins the Confiogure Global Security :

And select options like bellow and save changes :

Step 5: Create new admin account:

Create a new admin account :

Step 6: Login with the new admin account :

Finally, log in to Jenkins using the new admin user password to verify the password reset was successful.

For more information about Jenkins refer to Jenkins documentation.

You might also like

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *