If you too feel awful while keeping your password into plain string within, here is the way it might can help you.
Encrypt your password from OpenSSL using the below command
Assumption : Here i will be encrypting my plain text password as " mysecretpassword "
[root@cyberkeeda]# echo 'mysecretpassword' | openssl enc -base64 -e -aes-256-cbc -nosalt -pass pass:garbageKey
You will find a encrypted password output as
O7LX4VmomxrBgNHS+R1FcoNneSrqWFY0oTn3ammEF7w=
[root@cyberkeeda]# echo 'O7LX4VmomxrBgNHS+R1FcoNneSrqWFY0oTn3ammEF7w=' | openssl enc -base64 -d -aes-256-cbc -nosalt -pass pass:garbageKey
So it must provide a decrypted password as.
"mysecretpassword"
If it works fine, then you can simply save it into a file and use it within your script.
Encrypt it and save it into a hidden file.
[root@cyberkeeda]# echo 'mysecretpassword' | openssl enc -base64 -e -aes-256-cbc -nosalt -pass pass:garbageKey > .secret.lck
Then further you can call it within your script as.
#!/bin/bash
#Myscript.sh
#
#
PASS=`cat .secret.lck | openssl enc -base64 -d -aes-256-cbc -nosalt -pass pass:garbageKey
`
#
#You can use the secret password anywhere within your script.