diff options
author | Aoi Koizumi <novaburst@kalli.st> | 2022-01-28 20:34:31 -0300 |
---|---|---|
committer | Aoi Koizumi <novaburst@kalli.st> | 2022-01-28 20:34:31 -0300 |
commit | 46b1c4e1be64d3fa4be3597d87d469b8423b043e (patch) | |
tree | ba8ae0e5d89ef01d806d55a825398ec75502e134 | |
parent | c9e2e86b097d9e5b86f00aeeeedb18fce68e5ead (diff) | |
download | ayu-46b1c4e1be64d3fa4be3597d87d469b8423b043e.tar.gz |
Check the commit log for changes, there are a lot!
Signed-off-by: Aoi Koizumi <novaburst@kalli.st>
-rw-r--r-- | README | 30 | ||||
-rwxr-xr-x | ayu | 77 | ||||
-rw-r--r-- | ayu.mdoc | 62 |
3 files changed, 84 insertions, 85 deletions
diff --git a/README b/README index 8952f95..5d08259 100644 --- a/README +++ b/README @@ -1,17 +1,18 @@ ayu (あゆ) === -Not-so standard unix password manager, written in (mostly) posix shell +Not-so standard unix password manager, written in (mostly) posix shell (~90 LoC) Uses <https://age-encryption.org> as back-end, and tree(1) to list contents of the password store Caveats ------- For the utility to work, you have to generate your own keypair with age-keygen(1) -The private key should be placed as ~/.config/ayu/sec.age and the public key should be placed as ~/.config/ayu/pub.age +The private key should be placed as ~/.ayu/public_key and the public key should be placed as ~/.ayu/public_key -e.g. age-keygen -o ~/.config/ayu/sec.age and the output should be copied into the public key file. +e.g. age-keygen -o ~/.ayu/private_key && age-keygen -y ~/.ayu/private_key > ~/.ayu/public_key +Store is located by default on ~/.ayu-store/ Anti-features ------------- @@ -19,10 +20,29 @@ Anti-features 1) built-in integration with Git 2) built-in automatic keypair generation -neither of those are included and probably will never be. +Neither of those are included and probably will never be. Just use the CLI tools by themselves, lol. + +Dependencies +------------- + +1) age(1), duh! +2) mandoc (documentation) +3) tree +4) xclip (optional) + + +Related software +---------------- + +[angou]: <https://gt.kalli.st/shokara/angou> +[pa]: <https://github.com/biox/pa> +[page]: <https://github.com/e-zk/page> +[pass]: <https://passwordstore.org> + + License ------- -Discordian Public License, otherwise, MIT +Discordian Public License diff --git a/ayu b/ayu index 23ab4ec..b6b22c6 100755 --- a/ayu +++ b/ayu @@ -3,32 +3,41 @@ # ayu(1) - an actually boring password manager, which uses age(1) as backend. # Path to the program's directory -ayu_dir="${ayu_dir:-$HOME/.config/ayu}" +ayu_dir="${ayu_dir:-$HOME/.ayu}" # Path to the password store -ayu_store="${ayu_store:-$HOME/.ayu}" +ayu_store="${ayu_store:-$HOME/.ayu-store}" + +# Command to copy an entry's text into the clipboard (must accept standard input) +clipboard="xsel -ib" # Path to the age(1) keys -ayu_key="${ayu_key:-${ayu_dir}/sec.age}" -ayu_pub="${ayu_pub:-${ayu_dir}/pub.age}" +private_key="${private_key:-${ayu_dir}/private_key}" +public_key="${public_key:-${ayu_dir}/public_key}" +# Default editor to be used EDITOR=${EDITOR:-vi} # Run some tests test -d $ayu_dir || mkdir -p $ayu_dir test -d $ayu_store || mkdir -p $ayu_store -test -f $ayu_key || printf "$0: Generate your own age(1) key with age-keygen(1) and place it as a $ayu_key. \n" -test -f $ayu_pub || printf "$0: Public key needs to be placed on $ayu_pub (Hint: it's the visible output of age-keygen(1)) \n" +test -f $private_key || printf "$0: Generate your own age(1) key with age-keygen(1) and place it as a $private_key. \n" +test -f $public_key || printf "$0: Public key needs to be placed on $public_key (Hint: it's the visible output of age-keygen(1)) \n" # Switch directory to the password store, otherwise bail out. cd $ayu_store || exit 1 +# Copy an entry to the clipboard +copy() { + view "$2" | sed 1q | $clipboard +} + # Edit an entry if it exists edit() { - age --decrypt --identity=$ayu_key --output=${1%%.age} ${1%%.age}.age + age --decrypt --identity=$private_key --output=${1%%.age} ${1%%.age}.age ${EDITOR} ${1%%.age} - age --encrypt -R $ayu_pub --output=${1%%.age}.age ${1%%.age} + age --encrypt -R $public_key --output=${1%%.age}.age ${1%%.age} rm ${1%%.age} } @@ -45,31 +54,30 @@ new() { ${EDITOR} "$tmpfile" mkdir -p "$(dirname "$1")" - age --encrypt -R $ayu_pub -o $tmpfile.age $tmpfile + age --encrypt -R $public_key -o $tmpfile.age $tmpfile mv $tmpfile.age "${1%%.age}".age rm $tmpfile } # Remove -re() { - rm -v ${1}${2}.age -} -# Remove-recursive -rr() { - test -d "$@" && usage && exit - rm -r -v "$(dirname "$@")" +remove() { + rm -f ${1}${2}.age } +# Remove recursively +remove_recursive() { + rm -rf "$@" +} # Print usage usage() { - printf "$0 [ ed | ls | new | re | rr | vi ] \n" + printf "$0 [ -c | -e | -l | -n | -r | -R | -v ] <entry> \n" } # View an entry, otherwise list the contents of the directory specified. view() { if [ -f "${1%%.age}".age ];then - age --decrypt --identity=$ayu_key "${1%%.age}".age + age --decrypt --identity=$private_key "${1%%.age}".age elif [ -d "${1:-.}" ];then tree "${1:-.}" else @@ -79,28 +87,13 @@ view() { } case $1 in - edit | ed) - edit $2 - ;; - list | ls) - list - ;; - new) - new $2 - ;; - remove | re) - re $2 $3 - ;; - remove-recursive | rr) - rr $2 - ;; - usage) - usage - ;; - view | vi) - view $2 - ;; - *) - list - ;; + -c) copy $2 ;; + -e) edit $2 ;; + -l) list ;; + -n) new $2 ;; + -r) remove $2 $3 ;; + -R) remove_recursive $2 ;; + -h) usage ;; + -v) view $2 ;; + *) usage ;; esac diff --git a/ayu.mdoc b/ayu.mdoc index 73cce9e..ac4022c 100644 --- a/ayu.mdoc +++ b/ayu.mdoc @@ -1,4 +1,4 @@ -.Dd January 21, 2022 +.Dd January 28, 2022 .Dt ayu 1 .Os .Sh NAME @@ -17,63 +17,49 @@ or .Xr pass 1 .Pp There may be breaking changes but shouldn't be much. +.Pp +This silly thing could've been written in C or something +but there's already a Go variant using age's library. +.Pp +So it's not like I'm gonna care. .Sh USAGE .Ss Add an entry -.Nm ayu -.Sy new +.Nm +.Sy -n +.Em entry +.Ss Copy an entry's text to the clipboard +.Nm +.Sy -c .Em entry .Ss Edit an entry -.Nm ayu -.Sy edit +.Nm +.Sy -e .Em entry .Ss List entries -.Nm ayu -.Sy list +.Nm +.Sy -l .Ss Remove an entry -.Nm ayu -.Sy re +.Nm +.Sy -r .Em entry .Ss Remove recursively a directory with entries -.Nm ayu -.Sy rr +.Nm +.Sy -R .Em entry .Ss View an antry -.Nm ayu -.Sy view +.Nm +.Sy -v .Em entry -.Sh ALIASES -.Sy ed -Alias for -.Sy edit -.Pp -.Sy ls -Alias for -.Sy list -.Pp -.Sy re -Alias for -.Sy remove -.Pp -.Sy rr -Alias for -.Sy remove-recursive -.Pp -.Sy vi -Alias for -.Sy view .Sh CAVEATS You have to generate your own keypair using .Xr age-keygen(1) .Pp The private key should be placed on -.Em ~/.config/ayu/sec.age +.Em ~/.ayu/private_key and the public key to -.Em ~/.config/ayu/pub.age +.Em ~/.ayu/public_key for the utility to work .Pp -Side note: if the utility is invoked without any arguments, it defaults -to listing the entries on the password store. -.Pp .Sh AUTHORS .An Aoi Koizumi .Mt novaburst@kalli.st |