当前位置:   article > 正文

jenkins 查看凭证密码以及重置admin密码的操作方法_jenkins修改admin密码

jenkins修改admin密码

找回凭证密码

打开Jenkins的系统管理页面的脚本命令行页面
 

在这里插入图片描述

 在输入框输入如下代码点击运行即可查看所有凭证对应的密码

  1. com.cloudbees.plugins.credentials.SystemCredentialsProvider.getInstance().getCredentials().forEach{
  2.   it.properties.each { prop, val ->
  3.     println(prop + ' = "' + val + '"')
  4.   }
  5.   println("-----------------------")
  6. }

 

按下ctrl + F组合键查找凭证ID就能搜索到该凭证对应的密码

对单个凭据解密

jenkins下找到credentials.xml 文件中<password> 中对应的字符串,然后将该字符串拿到脚本命令行执行下面的命令解密

println(hudson.util.Secret.fromString("{AQAAABAAAAAQ56sZ/zqxgpZ59iss2x4xiL1l+7uo6Uz6XBVRVJ/07K0=}").getPlainText())


重置管理员密码为123456

admin用户信息默认存放在/root/.jenkins/users/admin/config.xml文件中, 注意对应自己的实际路径, 其中passwordHash标签中间的内容就是admin用户加密后的密码

  1. <?xml version='1.1' encoding='UTF-8'?>
  2. <user>
  3. <fullName>admin</fullName>
  4. <properties>
  5. <jenkins.security.ApiTokenProperty>
  6. <apiToken>{AQAAABAAAAAwzaSuZnmlQZdTqpGR+OJFsLttgq85/TvpE+HdXnDorJ5CVEyLKBZwWU23KNK1BMbhp5XOOVjn938Z+Xbop3z9Pg==}</apiToken>
  7. </jenkins.security.ApiTokenProperty>
  8. <hudson.model.MyViewsProperty>
  9. <views>
  10. <hudson.model.AllView>
  11. <owner class="hudson.model.MyViewsProperty" reference="../../.."/>
  12. <name>all</name>
  13. <filterExecutors>false</filterExecutors>
  14. <filterQueue>false</filterQueue>
  15. <properties class="hudson.model.View$PropertyList"/>
  16. </hudson.model.AllView>
  17. </views>
  18. </hudson.model.MyViewsProperty>
  19. <hudson.model.PaneStatusProperties>
  20. <collapsed/>
  21. </hudson.model.PaneStatusProperties>
  22. <hudson.search.UserSearchProperty>
  23. <insensitiveSearch>true</insensitiveSearch>
  24. </hudson.search.UserSearchProperty>
  25. <hudson.security.HudsonPrivateSecurityRealm_-Details>
  26. <passwordHash>#jbcrypt:$2a$10$MiIVR0rr/UhQBqT.bBq0QehTiQVqgNpUGyWW2nJObaVAM/2xSQdSq</passwordHash>
  27. </hudson.security.HudsonPrivateSecurityRealm_-Details>
  28. <jenkins.security.LastGrantedAuthoritiesProperty>
  29. <roles>
  30. <string>authenticated</string>
  31. </roles>
  32. <timestamp>1528791323260</timestamp>
  33. </jenkins.security.LastGrantedAuthoritiesProperty>
  34. </properties>
  35. </user>

 把该文件复制备份后修改就能把passwordHash标签中的值修改成#jbcrypt:2a10$MiIVR0rr/UhQBqT.bBq0QehTiQVqgNpUGyWW2nJObaVAM/2xSQdSq

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

重启jenkins后用admin账号登录,密码123456

 生成自定义密码

通过 https://github.com/jeremyh/jBCrypt 项目生成自定义密码, 只需要在该项目生成的hash值里面加上#jbcrypt: 之后再去替换/root/.jenkins/users/admin/config.xml 中的passwordHash值就行

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/130474
推荐阅读
相关标签
  

闽ICP备14008679号