I needed the same thing and was looking for solution. Apart from running gpg-agent
, which will ask for the password only once (e.g. during boot) and cache it for next usage, I have found nothing.
Problem is how to interact with interactive scripts, which are the ones, who ask for user input from stdin. Expect (apt-get install expect
) solves exactly that.
This is the script I wrote and saved in /usr/local/bin/reprepro_expect:
#!/usr/bin/expect -f
set timeout 2
set passphrase "mysupersecretpassword"
spawn reprepro -b [lindex $argv 0] [lindex $argv 1] [lindex $argv 2] [lindex $argv 3]
expect {
"*passphrase:*" {
send -- "$passphrase\r"
}
}
expect {
"*passphrase:*" {
send -- "$passphrase\r"
}
}
interact
You can run it like this:
reprepro_expect [path_to_repository] [command] [distribution] [package_name]
For example:
Add new package:
reprepro_expect /var/www/myrepo includedeb wheezy mypackage_0.1-1_all.deb
Delete package
reprepro_expect /var/www/myrepo remove wheezy mypackage
Security:
Since password to your private key is stored in the script, I recommend to chown
it to user, under which it will be used and chmod
it to 500. Why isn't passphrase passed as another argument? Because it would be stored in ~/.bash_history and it would show in ps axu
during runtime.