How to Reset Forgotten Jenkins Admin User's Password

reset jenkins password, reset jenkins user password, reset jenkin admin password, forgotten jenkins password, jenkin password reset, change users admin password

This post shows you how to reset the forgotten jenkins user password without disabling the security completely. Because, changing the security complete is not a good practice in production environment, this would make your jenkins environment secure less, so anybody can login without password. You can use this disabling security method only when you have a situation like authentication completely not working for anyone to manage jenkins not for reseting a password of jenkins users.

Let's get started.

How to Reset Forgotten Jenkins Admin User's Password

1. Generate hash password first for the user you wish to reset. Lets say i want to reset the password of admin user. You can follow the same procedure for any users.

Use "sha256sum" command to generate the hash password as below and make a note of the output that must be used while replacing the old password.
[root@jenkins-master ~]# echo -n 'redhat123{admin}' | sha256sum
b868ee6ad68d101ab46c8ee7569821917b4cd6375ad53ccd4d085a3e842a3bdd  -
[root@jenkins-master ~]# 
Where, "redhat123" is the new password and "admin" is the username. Replace these username and new password as per your user information.

2. Modify the user's config file to use the newly generated password.
While creating the user itself, config.xml file is generated for each user under the directory "/var/lib/jenkins/users/".

Go to the respective config file of the user "admin" and find the below line marked in yellow color.
[root@jenkins-master ~]# cat /var/lib/jenkins/users/admin/config.xml
<?xml version='1.1' encoding='UTF-8'?>
<user>
  <fullName>admin</fullName>
  <properties>
    <jenkins.security.ApiTokenProperty>
      <tokenStore>
        <tokenList/>
      </tokenStore>
    </jenkins.security.ApiTokenProperty>
    <hudson.model.MyViewsProperty>
      <views>
        <hudson.model.AllView>
          <owner class="hudson.model.MyViewsProperty" reference="../../.."/>
          <name>all</name>
          <filterExecutors>false</filterExecutors>
          <filterQueue>false</filterQueue>
          <properties class="hudson.model.View$PropertyList"/>
        </hudson.model.AllView>
      </views>
    </hudson.model.MyViewsProperty>
    <hudson.model.PaneStatusProperties>
      <collapsed/>
    </hudson.model.PaneStatusProperties>
    <hudson.search.UserSearchProperty>
      <insensitiveSearch>true</insensitiveSearch>
    </hudson.search.UserSearchProperty>
    <hudson.security.HudsonPrivateSecurityRealm_-Details>
 <passwordHash>#jbcrypt:$2a$10$EODrFXhix9FkkZnp6ekaQOy1ZKNSfylV7GXjFJk3X76p43DgV2mT6</passwordHash>
    </hudson.security.HudsonPrivateSecurityRealm_-Details>
    <jenkins.security.LastGrantedAuthoritiesProperty>
      <roles>
        <string>authenticated</string>
      </roles>
      <timestamp>1533733962643</timestamp>
    </jenkins.security.LastGrantedAuthoritiesProperty>
  </properties>
[root@jenkins-master ~]# 
[ads-post]
Remove only the passwordhash line and replace with your username and new password in the format below.
<passwordHash>admin:b868ee6ad68d101ab46c8ee7569821917b4cd6375ad53ccd4d085a3e842a3bdd</passwordHash>
Finally, your config.xml file must be looks like,
[root@jenkins-master ~]# cat /var/lib/jenkins/users/admin/config.xml
<?xml version='1.1' encoding='UTF-8'?>
<user>
  <fullName>admin</fullName>
  <properties>
    <jenkins.security.ApiTokenProperty>
      <tokenStore>
        <tokenList/>
      </tokenStore>
    </jenkins.security.ApiTokenProperty>
    <hudson.model.MyViewsProperty>
      <views>
        <hudson.model.AllView>
          <owner class="hudson.model.MyViewsProperty" reference="../../.."/>
          <name>all</name>
          <filterExecutors>false</filterExecutors>
          <filterQueue>false</filterQueue>
          <properties class="hudson.model.View$PropertyList"/>
        </hudson.model.AllView>
      </views>
    </hudson.model.MyViewsProperty>
    <hudson.model.PaneStatusProperties>
      <collapsed/>
    </hudson.model.PaneStatusProperties>
    <hudson.search.UserSearchProperty>
      <insensitiveSearch>true</insensitiveSearch>
    </hudson.search.UserSearchProperty>
    <hudson.security.HudsonPrivateSecurityRealm_-Details>
 <passwordHash>admin:b868ee6ad68d101ab46c8ee7569821917b4cd6375ad53ccd4d085a3e842a3bdd</passwordHash>
    </hudson.security.HudsonPrivateSecurityRealm_-Details>
    <jenkins.security.LastGrantedAuthoritiesProperty>
      <roles>
        <string>authenticated</string>
      </roles>
      <timestamp>1533733962643</timestamp>
    </jenkins.security.LastGrantedAuthoritiesProperty>
  </properties>
[root@jenkins-master ~]# 
Restart Jenkins Service to take the changes effect.
[root@jenkins-master ~]# systemctl restart jenkins
Now you would be able to login with new password. Hope you have got an idea how to reset jenkins user password. Going forward we will play more with jenkins integration tool. Keep practicing and have fun. Leave your comments if any.

Also refer other articles,

How to Install & Configure Jenkins Integration tool on Linux
What is Docker - Get Started from Basics - Docker Tutorial
What is Container, What is Docker on Container - Get Started
How to Install Docker on CentOS 7 / RHEL 7
Docker Images Explained with Examples - Docker Tutorial
Dockerfile Instructions Explained with Examples
Docker CMD & ENTRYPOINT Differences Explained in Detail
How to Run Docker Containers - Explained with Examples

Support Us: Share with your friends and groups.

Stay connected with us on social networking sites, Thank you.
YouTube | Facebook | Twitter | Pinterest | Rss
Keywords: reset jenkins password, reset jenkins user password, reset jenkins admin password, forgotten jenkins password, reset forgotten jenkins password, how to reset forgotten jenkins password, jenkins password reset, jenkins reset password cli, jenkins reset password hash, jenkins reset password for user, how to reset password for user in jenkins, reset passwords, change users password, change jenkins users password, change jenkins admin password, jenkins tips, jenkins tricks, jenkins realtime issues, jenkins realtime scenerios
August 08, 2018

Post a Comment

[disqus][facebook][blogger]

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget