To change the default password on Jenkins, you typically use the Jenkins web interface. Here's how you can do it:
-
Log in to Jenkins: Open your web browser and navigate to your Jenkins instance. Log in using your current username and password.
-
Access User Management: Once logged in, click on your username in the top right corner of the Jenkins dashboard. This will open a drop-down menu. From the menu, select "Configure". Make yo select your user
-
Change Password: In the User Configuration page, you should see an option to change your password. It might be labeled as "Change Password" or "Password". Click on it, and it will allow you to enter a new password.
follow the steps below -
Save Changes: After entering the new password, make sure to save the changes by clicking on the "Save" or "Apply" button at the bottom of the page.
-
Verify the New Password: Log out of Jenkins and log back in using the new password to ensure that it has been changed successfully.
If you've forgotten your password and cannot log in to Jenkins, you can reset the password by following these steps:
-
Stop Jenkins: If Jenkins is running as a service, stop it. with the command below:
systemctl stop jenkins
-
Locate Jenkins Home Directory: In the Jenkins home directory (commonly located at /var/lib/jenkins on Unix-like systems), you'll find a file named config.xml. by using this command on the server containing jenkins;
su jenkins cd
-
Edit config.xml: Open config.xml in a text editor and search for the <useSecurity> element. Change its value to false to disable security temporarily.
-
Start Jenkins: Start Jenkins again. Using this command
systemctl start jenkins
-
Reset Password: Navigate to the Jenkins web interface and log in. Since security is temporarily disabled, you'll be able to access Jenkins without authentication. Go to the User Configuration page as described earlier and change your password.
-
Enable Security: After resetting your password, stop Jenkins again. Then, edit config.xml to set <useSecurity> back to true to re-enable security.
-
Restart Jenkins: Start Jenkins again. Now, your password has been successfully changed, and security is enabled. Using this command
systemctl restart jenkins
Remember to always handle passwords securely and follow best practices for password management to ensure the security of your Jenkins instance.