bitagent has been pushed to GitHub. An agent that let’s you easily store arbitrary secrets for sharing between programs and login sessions on the same computer. The inspiration for this project was Bitwarden. Bitwarden is an excellent password manager that supports all major OSs, and includes a web interface, a desktop GUI, and a CLI interface.
The CLI workflow is something like this:
> $ bw unlock ? Master password: [input is hidden] Your vault is now unlocked! To unlock your vault, set your session key to the `BW_SESSION` environment variable. ex: $ export BW_SESSION="<session key>" > $env:BW_SESSION="<session key>" You can also pass the session key to any command with the `--session` option. ex: $ bw list items --session <session key> > $ export BW_SESSION="<session key>" > $ bw get username MyWebsite firstname.lastname@example.org
Despite the very clear instructions, you can see a problem forming here. The session key is only valid while the vault is unlocked, but it needs to be shared with any invocation of
bw. As someone who is acustomed to using things like Bitwarden and Vault, the thought of saving this session key to disk, no matter how temporary, makes me feel uneasy.
So why not simply wrap the call to
bw unlock in something that automatically sets the session key in
BW_SESSION? That’s part of the solution, but how does that variable get shared with other shells you open?
Enter bitagent and a wrapper script. The
bw script wraps the
bw command, but instead of simply exporting the
BW_SESSION variable, it also writes it to an instance of bitagent via its Unix socket. Now using the
bw wrapper instead of the original command, the workflow looks like this.
> $ bw unlock ? Master password: [hidden] Success > $ bw get username MyWebsite email@example.com
Much quicker, and more importantly, another shell can be opened and the
bw wrapper can be used right away without setting an environment variable, copying a session key (and having it then written to the shell’s history file and put in the output of
ps), or running
Please give bitagent a try and send suggestions, PRs, bug reports, and contribute wrapper scripts that you find useful.
2019-05-22 14:48 -0700