What password encryption Jenkins is using?

后端 未结 3 1164
盖世英雄少女心
盖世英雄少女心 2020-12-09 15:46

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

3条回答
  •  渐次进展
    2020-12-09 16:15

    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.

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

提交回复
热议问题