3

I have created an Admin account in Jenkins after unlocking the Jenkins and doing the initial setup. Now I have forgot the password of the admin account and I am not able to login Jenkins

MaratC
  • 6,418
  • 2
  • 20
  • 27
Shubham Parmar
  • 147
  • 1
  • 13
  • Does this answer your question? [How to reset Jenkins security settings from the command line?](https://stackoverflow.com/questions/6988849/how-to-reset-jenkins-security-settings-from-the-command-line) – Joao Vitorino Nov 22 '19 at 15:02

3 Answers3

5

First, enter the docker container by using

sudo docker exec -it [containerID] bin/bash

Your container is likely clean and need to install editing tools, run

apt-get update && apt-get install nano

Then, find the config.xml file. For my container, it is in /var/jenkins_home/config.xml. You can also try /var/lib/jenkins/config.xml.

nano /var/jenkins_home/config.xml

Terminal Screen Cap Change the useSecurity tag to false.

docker restart [ContainerID]

Now, you can visit the Jenkins page and it should be showing the Dashboard right the way without password. You should reset the password, by going to Dashboard -> Manage Jenkins -> Security -> Configure Global Security , set Security Realms to Jenkins' own user database and press Apply.

Next, go to People and click the admin account, you should be redirected and see a button named Configure, set a new set of password in Password section and press Apply.

Then, go to Configure Global Security again, set Authentication to the option other than Anyone can do anything

Your password should have been reset, finally, go set the value of useSecurity to true again and restart the container. Hope this help!

v.ng
  • 533
  • 5
  • 10
0

As you running Jenkins in a Docker container you have to go to the inside of the container.

by typing below command $docker exec -it (container-ID) /bin/bash

After entering the container you should follow these step which mentioned on this post https://techpostal.blogspot.com/2020/01/how-to-reset-jenkins-admin-password.html

then check it and one more thing when you are done with the resetting password you shoud commit the docker images for future use of that image.

ramya ranjan
  • 21
  • 1
  • 1
  • 4
0

If you are using docker, all of that described before seems to me too much of a hazzle.

  1. Remove container and volumes used
  2. Start afresh again

Reference: https://www.jenkins.io/doc/book/installing/docker/

davidmpaz
  • 1,194
  • 15
  • 18
  • 1
    I think this is not a good approach as you want to keep the settings configured in Jenkins, killing and start another Jenkins container is not helping. – v.ng Aug 10 '22 at 16:56
  • The OP stated he is starting to use jenkins on a docker container, as I understand is a new fresh instance, so nothing to keep, or did I miss something? – davidmpaz Aug 11 '22 at 16:11