I can only upload an existing jenkins secret file not download the existing one.
How do I download an existing secret file I uploaded to confirm its contents?
Encryption of Secrets and Credentials. Jenkins uses AES to encrypt and protect secrets, credentials, and their respective encryption keys. These encryption keys are stored in $JENKINS_HOME/secrets/ along with the master key used to protect said keys.
Secret file - click the Choose file button next to the File field to select the secret file to upload to Jenkins. SSH Username with private key - specify the credentials Username, Private Key and optional Passphrase into their respective fields.
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.
If you have shell access to and sudo/root
/Jenkins Unix user permissions on the machine running Jenkins, you can retrieve the secret file by doing the following:
MY_SECRET_FILE_TXT
.In the Command text area, add the following shell script:
echo "executing user is $(whoami)"
# remove my-secret-file.txt before possibly getting an overwriting error
rm -f $WORKSPACE/my-secret-file.txt
echo "Jenkins project workspace: $WORKSPACE"
cp $MY_SECRET_FILE_TXT $WORKSPACE
The next time a build is triggered for this project, the secret file should appear in this project's workspace, i.e. at location $WORKSPACE/my-secret-file.txt
. As an example, on my Ubuntu 14.04.5 LTS installation with installed package and daemonjenkins
, that location is /var/lib/jenkins/workspace/$JENKINS_PROJECT_NAME/my-secret-file.txt
I usually extract secrets from jenkins by creating a job like this:
Jenkins masks all the keys in the output, so just replace one character when you print it out. If it turns out there is another 0
in your key, it'll appear as *******
and you can try replacing a different character, or splitting it in two and printing the two halfs on different lines, or another similar trick.
You can also just stick it straight into a file like this.
echo $HELLO > slack-key.txt
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