Skip to main content



Use Encrypted Password in Linux / Unix Shell Script

 

Easiest available way is using Openssl


Encrypt 

Say your actual password is "Password12345". You can encrypt using below command -

echo "Password12345" | openssl enc -aes-256-cbc -md sha512 -a -pbkdf2 -iter 100000 -salt -pass pass:Secret@1234# > secret.txt

Resultant output in "secret.txt"

U2FsdGVkX1/2NoQ6i1uZKK4yk+5gm5cA13EJ2TiPbcw=


Save this in a file and use it with your applications.

Decrypt 

Then you can read file with encrypted password, decrypt it using below command and pass it to henceforth operations/ commands.

cat "secret.txt" | openssl enc -aes-256-cbc -md sha512 -a -d -pbkdf2 -iter 100000 -salt -pass pass:Secret@123#

Resultant output 

Password12345

Comments