当前位置:网站首页>Jenkins can view the forgotten credential password based on the credential ID and how to reset the admin password

Jenkins can view the forgotten credential password based on the credential ID and how to reset the admin password

2022-06-09 01:25:00 kainx

Retrieve voucher password

  • open Jenkins The script command line page of the system management page  Insert picture description here
  • Enter the following code in the input box and click Run to view the passwords corresponding to all vouchers
com.cloudbees.plugins.credentials.SystemCredentialsProvider.getInstance().getCredentials().forEach{
    
  it.properties.each {
     prop, val ->
    println(prop + ' = "' + val + '"')
  }
  println("-----------------------")
}

 Insert picture description here Press down ctrl + F Key combination to find vouchers ID The password corresponding to the voucher can be searched

Reset the administrator password to 123456

admin User information is stored in by default /root/.jenkins/users/admin/config.xml In file , Pay attention to your actual path , among passwordHash The content in the middle of the label is admin The encrypted password of the user

<?xml version='1.1' encoding='UTF-8'?>
<user>
  <fullName>admin</fullName>
  <properties>
    <jenkins.security.ApiTokenProperty>
      <apiToken>{AQAAABAAAAAwzaSuZnmlQZdTqpGR+OJFsLttgq85/TvpE+HdXnDorJ5CVEyLKBZwWU23KNK1BMbhp5XOOVjn938Z+Xbop3z9Pg==}</apiToken>
    </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$MiIVR0rr/UhQBqT.bBq0QehTiQVqgNpUGyWW2nJObaVAM/2xSQdSq</passwordHash>
    </hudson.security.HudsonPrivateSecurityRealm_-Details>
    <jenkins.security.LastGrantedAuthoritiesProperty>
      <roles>
        <string>authenticated</string>
      </roles>
      <timestamp>1528791323260</timestamp>
    </jenkins.security.LastGrantedAuthoritiesProperty>
  </properties>
</user>

After copying and backing up the file, you can modify it passwordHash Change the value in the label to #jbcrypt:2a10$MiIVR0rr/UhQBqT.bBq0QehTiQVqgNpUGyWW2nJObaVAM/2xSQdSq

<hudson.security.HudsonPrivateSecurityRealm_-Details>
     <passwordHash>#jbcrypt:$2a$10$MiIVR0rr/UhQBqT.bBq0QehTiQVqgNpUGyWW2nJObaVAM/2xSQdSq</passwordHash>
</hudson.security.HudsonPrivateSecurityRealm_-Details>

restart jenkins After use admin To login , password 123456

Reference resources

1. https://blog.csdn.net/u012440725/article/details/124751053
2. https://blog.csdn.net/kai_1215/article/details/80731328

原网站

版权声明
本文为[kainx]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/160/202206090118509599.html