Answer a question

I just noticed I cannot login in my Jenkins.

How can I reset my password and access to my account again? I do not see any link to recover passwords and they seem to be hashed in the installation directory.

Answers

In How to reset password of Jenkins you have a set of tricks to make this happen. I based my solution on it, but it diverges in a certain point.

This is what I did to solve the issue:

Let's assume Jenkins' directory is stored in $JENKINS (in my machine this is /var/lib/jenkins/) and your username is user.

  • Allow signups by disabling disableSignup. This means editing $JENKINS/config.xml and setting this option to false:

    <disableSignup>false</disableSignup>
    
  • Restart Jenkins (service jenkins restart).

  • Enter in Jenkins and register a new user, for example testuser, with the password being the one you want to set to your user user.

  • Extract the hashed password from $JENKINS/users/testuser/config.xml. You will see something like:

    <passwordHash>#jbcrypt:$2a$10$PY7p4dxFiGSgJpxiNVTQDuJKAQ8pr9snDgQXaafogjErvgB0oC3qy</passwordHash>
    
  • Set the user's password to this one in <passwordHash>. That is, edit $JENKINS/users/user/config.xml and replace the password there to set the one above.

  • Disallow signups back by enabling disableSignup. That is, in $JENKINS/config.xml set the disableSignup option back to true:

    <disableSignup>true</disableSignup>
    
  • Restart Jenkins again.

Note you can also replace the password directly by generating a jBCrypt. For example, in http://www.mindrot.org/projects/jBCrypt/ you can find some Java code for it.

Logo

CI/CD社区为您提供最前沿的新闻资讯和知识内容

更多推荐