简体   繁体   中英

decrypt password in a bash script

I'd like to prepare a simple script for connecting to some VPN network. The password to the network consists of two elements: pretty complicated pass + randomized token. I don't want to remember this password but store it encrypted in some secure directory. Now, the script I need should ask me for a passphrase and some token, read decrypt a pass from a file and run some commands. All those are pretty easy except one thing: is it possible to decrypt a file to a variable instead of file? I mean I'd like to get something like

PASS=`mdecrypt password.nc`

but as far as I know mdecrypt generates a file as a result instead of returning value. I know I could run something like

`mdecrypt password.nc`
PASS=`cat password`
`unlink password`

but is there some easier (one liner) solution?

uset the -F option

-F Force output on standard output or input from stdin if that is a terminal. By default mcrypt will not output encrypted data to terminal

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM