1

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?

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

Didn't help: mdecrypt iweb_pass.nc -F mdecrypt: iweb_pass already exists; do you wish to overwrite (y or n)?y Enter passphrase: File iweb_pass.nc was decrypted.
But the file name I specified is in fact where I store encrypted data - otherwise how mdecrypt will determine what should it decrypt?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.