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

查看:1198
本文介绍了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 了解更多详情

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

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