You are not logged in.
Hey, I need to safely get a password in my bash script for encrypting some files. Currently my script just listens on a named pipe for something to come through and uses that for encrypting (I wasn't sure if it was safe to type a password in a shell script).
I would prefer something non-interactive if at all possible. This is going to be a cron job, so if it has to be interactive, it should be able to get my input without a terminal emulator. Any suggestions?
Offline
Non-interactive is counter-intuitive to what passwords are for...
What is the problem you're trying to solve?
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
</dev/urandom tr -dc [:graph:] | head -c<length of desired password>
Last edited by xstaticxgpx (2009-05-27 03:59:02)
Offline
read -s
-s Silent mode. If input is coming from a terminal, characters are not echoed.
Offline
Non-interactive is counter-intuitive to what passwords are for...
What is the problem you're trying to solve?
I need a cron job to encrypt something with a password. If I store the password in plain text, I lose security. If it requires input, then it's not very useful to schedule it. I wasn't really thinking that hard when I asked this question. I should have known that there wasn't really any way to reconcile these two needs.
Maybe I'll just go with the "security through obscurity" route... my root partition is encrypted anyways, and with proper permissions on the file I could be pretty sure that nobody will read the password. Throw in some obfuscated code and hope that nobody really, really smart gets ahold of my computer while it's running.
Offline
If you could use gpg then it would solve your problem - for encryption only the public key is required.
Offline
Well yes, but it's a backup script. I can't count on having my private key if I lose all my files. I may end up using gpg anyway though... all the solutions here are less than ideal.
Last edited by fflarex (2009-05-27 07:46:14)
Offline
You can create a special key for backups (so that you can't compromise your usual key) and then print the private key on paper - I know, not ideal, but it should be good enough for backups.
Offline
There's a thing called the Law of Diminishing Returns too...
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
There's a thing called the Law of Diminishing Returns too...
Well he has to decide what's more important: having the backups well encrypted or having them easily available but with the password not so well hidden [I mean running without user interaction means that the password has to be written somewhere. Although since the root is encrypted, it is probably sufficient to actually have it written somewhere on disk - after all the secret gpg key is also written somewhere on the disk and protected by a password. If the main concern is not compromised machine but backups stored somewhere else, then it's about the same level of safety.]
Offline