How to reset Jenkins Admin password?
When you try to access Jenkins console using PublicIp:port number, it will prompt to enter username and password.
If you forgot username or password or both, follow below steps to reset.
First connect to the Jenkins server, using any of the ssh tools like MobaXterm or putty.
After ssh to the server, Switch to root user using command ‘sudo su — ‘
and switch to Jenkins home directory using command ‘cd /var/lib/jenkins’
sudo su -
cd /var/lib/jenkins
in the Jenkins home directory(var/lib/jenkins) we will find a file called config.xml.
ls -l
open the config.xml and edit. Here I used vi for edit
vi config.xml
change it to ‘false’ and save the file using command :wq after clicking ‘esc’
now restart the Jenkins, and then check the status of the Jenkins using below commands
systemctl restart jenkins
systemctl status jenkins
Jenkins is active
Now go to Jenkins console and refresh, now you are able to access console without username and password.
To reset the password follow below procedure.,
in the Jenkins Dashboard click on ‘Manage Jenkins’ and then scroll down a little and click on ‘Security’
dashboard → Manage Jenkins → security
then select ‘Jenkins own user database’ from the ‘Authentication’ dropdown, and then click on ‘Save’.
Now go back to the Jenkins Dashboard, click on Manage Jenkins, and then click on users
Note: the users is appeared after we select ‘Jenkins own user database’ in the previous step.
here we will see all the users of Jenkins, here I have only admin user.
As we want to reset admin user password click on ‘settings’ icon.
scroll down and Enter whatever password you want for the admin user , and click on save
Hurray…. you have reset the password successfully.
check
Now enter username and new password. and click on sign in.
like this you can set the password to Admin user.
Follow this Best practice:
Just by browsing publicIp:8080, without login using user name and password, all users have access to manage Jenkins option, and to previously run job details like below figure
to restrict access to manage Jenkins tab, click on manage Jenkins, then security , scroll down a bit you will find Authorization, from Authorization dropdown select ‘Logged-in users can do anything’. and click on save.
Now access Jenkins using publicIp:8080, now you don’t find, manage Jenkins and previously run job information, without entering username and Password. and it will prompt to enter username and password.
now with the new password, you can sign in to Jenkins server.
Happy Learning :)