[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Feeding passphase in a script?



I did a little digging on this and while it may be possible, it is not "easy". The way tarsnap-keymgmt is currently coded, it reads the password with a function which always (when parameter devtty==1, which is the case here) checks if it can open /dev/tty first, and only if it can't will it fall back to reading from stdin.

So you'll need to run your command in a process that has no controlling terminal. "cron" and "at" will does this, and you might also have luck playing with "expect" (although I haven't tried it.)

Unfortunately, when I ran your example command from "at", it gave the following error:

tarsnap-keymgmt: Cannot set terminal settings: Input/output error
tarsnap-keymgmt: Error reading password

and that's as far as I got.

Chris

On 10/28/25 09:46, Rihad wrote:
Hi, I need to create a passphrased key in a shell script, and while testing it in a console it's still asking for the passphrase. Any way to do that easily?


$ echo -e "MyStrongPassword\nMyStrongPassword" | tarsnap-keymgmt -- outkeyfile outkeyfile -w -r -d --nuke --passphrased keyfile
Please enter passphrase for keyfile encryption: