Skip to content

yasammez/zoo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zoo

A command line password manager

About

zoo is a password managing daemon built atop ring.rs intended for usage on servers where other GUI-like options are not available or impractical.

Installation

cargo install --git https://github.com/yasammez/zoo.git

Usage

Once you have installed zoo, invoke it. It will ask you for a master password and then drop to the background. Do not lose that password! It will then listen on a unix domain socket located at $HOME/.local/share/zoo/socket. You can connect to it via openbsd netcat nc -U ~/.local/share/zoo/socket and issue commands directly. All changes made are instantaneously persisted, so be careful. Recognized commands are

  • ?: get a list of all commands
  • put <key> <secret>: create a new secret or override the value of an existing one
  • del <key>: remove the associated secret from the vault
  • get <key>: obtain the associated secret
  • lst: get a list of all known keys
  • off: shutdown the daemon

Examples

Tmux Statusline

Personally, I use zoo to provide my tmux statusline with a count of unread emails from various accounts. To this end, here are a couple helper scripts, written in fish (if that doesn't tickle your fancy, they should be easy to convert to something more POSIXy.

getpass.fish

function getpass --description 'get a password, fail if not found'
       echo -e "get $argv[1]\n" | nc -U ~/.local/share/zoo/socket | sed '/^val/!{q1}; s/^val //'
end

getmail.fish

function getmail --description 'get number of unread email in mailaccount'
        set pass (getpass $argv[2]); or return 1
        curl -s --url "imaps://$argv[1]:993/inbox;UID=1" --user "$argv[2]:$pass" -X 'STATUS INBOX (UNSEEN)' | sed 's/.*(UNSEEN \([0-9]*\))/\1/' | tr -d '\r\n'
end

updatemail.fish

function updatemail
        set result
        set accounts 'name:imap.example.com:user'
        for account in $accounts
                set args (string split : $account)
                set count (getmail $args[2] $args[3]); or return 1
                if [ "$count" != "0" ]
                        set result $result "$args[1] $count"
                end
        end
        echo $result > ~/.local/share/mailcount
end

I then include updatemail in my crontab to update the mailcount-file regularly and finally include a section #(cat ~/.local/share/mailcount) in my tmuxline preset.

Result

Screenshot

Git Credentials

You can use zoo as your git credential store as well. For this I configured my git with

git config --global credential.helper '!fish -c "git-credential-zoo $0"'

which makes use of the following function:

function git-credential-zoo
        if [ $argv[4] != "get" ]
                return
        end
        while read line
                set kv (string split "=" $line)
                if [ $kv[1] = "username" ]
                        set pass (getpass $kv[2]); or return 1
                        echo "password=$pass"
                end
        end
end

About

a command line password manager

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages