随笔 - 105  文章 - 2 评论 - 9 阅读 - 19万
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

找回凭证密码

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

 

 

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

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

 

 

 

 

 

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

对单个凭据解密

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

注意:这里不是解密,只是匹配,所以只能获取本jenkins里的明文密码,其他主机上的Jenkins密码获取不了

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


重置管理员密码为123456

admin用户信息默认存放在/root/.jenkins/users/admin/config.xml文件中,

注意:这里对应自己的实际路径,也有可能为 $jenkins_home/users/admin_4499542599441604470/config.xml

其中passwordHash标签中间的内容就是admin用户加密后的密码

复制代码
 
<?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>
复制代码

 

 把该文件复制备份后修改就能把passwordHash标签中的值修改成  #jbcrypt:$2a$10$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值就行

 

转自:https://blog.csdn.net/qq_30436011/article/details/127769206

posted on   06  阅读(4524)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
点击右上角即可分享
微信分享提示