I have added an SSH credential to Jenkins.
Unfortunately, I have forgotten the SSH passphrase and would now like to obtain it from Jenkins' credential archive, which is located at ${JENKINS_HOME}/credentials.xml
.
That XML document seems to have credentials encrypted in XML tags <passphrase>
or <password>
.
How can I retrieve the plaintext passphrase?
And in order to get the password value of ${ENCRYPTED_PASSPHRASE_OR_PASSWORD} : go to credentials, update, in the browser "See source code" and you will get the encrypted password in the data field for password. Then use that function.
Go to the jenkins workspace and look inside the file. The token will be present in plain text there. Further easy way will be to print the base64 encoded value of the credential and then decode it.
Although most credentials are stored in http://localhost:8080/credentials/ view, you can find additional secrets in: http://localhost:8080/configure - some plugins create password type fields in this view. http://localhost:8080/configureSecurity/ - look for stuff like AD credentials.
Open your Jenkins' installation's script console by visiting http(s)://${JENKINS_ADDRESS}/script
.
There, execute the following Groovy script:
println( hudson.util.Secret.decrypt("${ENCRYPTED_PASSPHRASE_OR_PASSWORD}") )
where ${ENCRYPTED_PASSPHRASE_OR_PASSWORD}
is the encrypted content of the <password>
or <passphrase>
XML element that you are looking for.
First, you need to get the encrypted value which is conveniently placed in the value
attribute of the password field of that credentials item you are interested in. Navigate to the credentials item in Jenkins UI you, click Inspect Element on the password field, and copy its value
attribute (something like {AQAABAAAa6VBbyzg5AWMW2RnfaBaj46}
Then, go to JENKINS_URL/script
and execute println( hudson.util.Secret.decrypt("{AQAABAAAa6VBbyzg5AWMW2RnfaBaj46}") )
; decrypted password appears under the input field
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With