Jenkins 使用什么密码加密? [英] What password encryption Jenkins is using?

查看:25
本文介绍了Jenkins 使用什么密码加密?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在修改 Jenkins 作业的 xml.有一个字段是密码.当我得到 xml 时,它是原始密码,现在有一个哈希值.

I am modifying an xml of a Jenkins job. There is a field which is a password. When I get the xml, where it was the raw password now there is a hash.

我需要的是知道如何从原始密码值创建这个哈希.

What I need is to know how to create this hash from the raw password value.

  <scm class="com.deluan.jenkins.plugins.rtc.JazzSCM">
    <username>user</username>
    <password>zlvnUMF1/hXwe3PLoitMpQ6BuQHBJ1FnpH7vmMmQ2qk=</password>
  </scm>

我一直在阅读 Jenkins 源代码,我认为涉及 HudsonPrivateSecurityRealm.java 类,但我不确定 salt 参数.

I have been reading Jenkins source code and I think the class HudsonPrivateSecurityRealm.java is involved but I am not sure about the salt parameter.

PS:这不是针对 Jenkins 密码,而是针对在作业配置中具有密码字段的插件.

PS: This is not for the Jenkins password is for a plugin which in the job configuration it has a password field.

推荐答案

实际上,它不是散列而是加密的密码.我猜加密密钥存储在主节点中.实际上,您可以通过在 master 的脚本控制台上执行以下 groovy 脚本来解密密码

In fact, it's not a hash but rather an encrypted password. I guess encryption keys are stored in the master node. Actually, you can decrypt the password by executing following groovy script on master's script console

import hudson.util.Secret

def secret = Secret.fromString("zlvnUMF1/hXwe3PLoitMpQ6BuQHBJ1FnpH7vmMmQ2qk=")
println(secret.getPlainText())

如果你想加密密码,那么

and if you want to encrypt the password, then

import hudson.util.Secret

def secret = Secret.fromString("your password")
println(secret.getEncryptedValue())

在计算机上加密的密码只能在该特定计算机上解密,因为密钥是随机生成的,显然在不同的机器上,密钥是不同的.

A password encrypted on a computer can be decrypted only on that particular computer since keys are randomly generated and obviously on different machines the keys are different.

查看 core/src/main/java/hudson/util/Secret.java 了解更多详情

Check out core/src/main/java/hudson/util/Secret.java for more details

这篇关于Jenkins 使用什么密码加密?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆