[pass] [PATCH] Allow file input for insert
milki
milki at rescomp.berkeley.edu
Fri Sep 28 00:42:10 CEST 2012
Specify an additional file argument to insert as password contents
pass insert pass-name pass-file
Use cases - storing private ssh keys, gpg keyrings, longer list of
sensitive data.
I want pass to be able to store and associate private keys to
different user/host combos. With pass+git, now I would have
an easier way to manage the private keys across hosts.
Could also be used for non-password sensitive data that someone wanted
to manage with pass...
Yes, some files will end up being multiply encrypted, but the
encryption schemes are different and all the files stored in
password-store use a common encryption key.
---
src/password-store.sh | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/password-store.sh b/src/password-store.sh
index 503bac4..72b0ca5 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -38,7 +38,7 @@ Usage:
$program [show] [--clip,-c] pass-name
Show existing password and optionally put it on the clipboard.
If put on the clipboard, it will be cleared in 45 seconds.
- $program insert [--no-echo,-n | --multiline,-m] [--force,-f] pass-name
+ $program insert [--no-echo,-n | --multiline,-m] [--force,-f] pass-name [pass-file]
Insert new password. Optionally, the console can be enabled to not
echo the password back. Or, optionally, it may be multiline. Prompt
before overwriting existing password unless forced.
@@ -243,8 +243,8 @@ case "$command" in
--) shift; break ;;
esac done
- if [[ $err -ne 0 || ( $multiline -eq 1 && $noecho -eq 1 ) || $# -ne 1 ]]; then
- echo "Usage: $program $command [--no-echo,-n | --multiline,-m] [--force,-f] pass-name"
+ if [[ $err -ne 0 || ( $multiline -eq 1 && $noecho -eq 1 ) || ($# -ne 1 && $# -ne 2) ]]; then
+ echo "Usage: $program $command [--no-echo,-n | --multiline,-m] [--force,-f] pass-name [pass-file]"
exit 1
fi
path="$1"
@@ -258,6 +258,9 @@ case "$command" in
echo "Enter contents of $path and press Ctrl+D when finished:"
echo
$GPG -e -r "$ID" -o "$passfile" $GPG_OPTS
+ elif [[ $# -eq 2 ]]; then
+ echo "Using $2 as the password file"
+ $GPG -e -r "$ID" -o "$passfile" $GPG_OPTS $2
elif [[ $noecho -eq 1 ]]; then
while true; do
read -p "Enter password for $path: " -s password
--
1.7.11.5
More information about the Password-Store
mailing list