28

I've taken over the project where a lot of Jenkins credentials has passwords or passphrase strings which I need to know in order to progress with the project, unfortunately these weren't documented anywhere.

I've checked the credentials.xml file where these credentials are stored, but they're in not plain text, e.g.:

<passphrase>{AAAAAAAAAAAANzxft/rDzyt8mhxpn3O72dxvVqZksL5vBJ4jNKvAjAA=}</passphrase>

Note: I've changed it slightly for privacy reasons.

How can I decrypt its original password based on the string above?

  • I am getting error with the proposed answer: println(hudson.util.Secret.decrypt("{{xxx/wwww+yyyy/zzzz=}}")) The + symbol is breaking the script. Any suggestion? – Jay Bau Jun 14 at 17:35
  • @JayBau Try with single brackets: "{...}", remove extra once. – kenorb Jun 17 at 11:37
32

Luckily there is a hudson.util.Secret.decrypt() function which can be used for this, so:

  1. In Jenkins, go to: /script page.
  2. Run the following command:

    println(hudson.util.Secret.decrypt("{XXX=}"))
    

    or:

    println(hudson.util.Secret.fromString("{XXX=}").getPlainText())
    

    where {XXX=} is your encrypted password. This will print the plain password.

    To do opposite, run:

    println(hudson.util.Secret.fromString("some_text").getEncryptedValue())
    

Source: gist at tuxfight3r/jenkins-decrypt.groovy.


Alternatively check the following scripts: tweksteen/jenkins-decrypt, menski/jenkins-decrypt.py.


For more details, check: Credentials storage in Jenkins.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.