Sharing passwords using gopass, git and gpg
Background
For quite some time, I've been trying to solve this problem I had in my mind. I was looking for a way to store my passwords (I'll refer to them as secrets also) in a secure way. But also, I wanted these features:
Storing passwords in the cloud
Easy to synchronize between devices
Easy to share between teammates (groups)
The solution I found was gopass.
How it works
Basically gopass is like pass (the unix password manager) with an extra pair of batteries.
Among others, the features it has, relevant to me, are:
Uses gpg for secrets encryption.
Uses git for secrets synchronization.
Multiple password's stores (personal, company, etc).
Each store can point to a different repository.
Support for multiple people per store, called recipients in the jargon.
Even though it lacks a bit in documentation, the commands just do what's expected of them. So don't be afraid to play with it.
Regarding gpg, it makes me glad to start wrapping my mind around it, and gopass using it, well, makes my day :)
The only drawback I found is the lack of official windows support. I don't know if it works or not in windows.
Installation
You can check the website's installation or you can go to a more in depth explanation in gopass repo.
Usage
First of all, we are gonna need a gpg key. To create one, gopass it's not needed. Instaed, we are gonna use gpg cli that should be in your system if you have installed gopass.
How does gpg work?
In the context of gopass, we are gonna use the public and private keys provided by gpg.
Imagine you have an infinite amount of boxes (public key), that once they are closed, they can only be open with a key that only you have (private key).
From this analogy, we can conclude 2 things:
1. You can distribute your public keys and let anyone encrypt information with it. Let's say I give boxes to friends, they put something inside and close it. That's it, only I will be able to open it. And of course, I can also encrypt my stuff, in case some is sniffing around.
2. Private keys are really important, keep them safe, don't lose them, and make a backup. You can use an encrypted pendrive, a paper note in a safe place, or a yubikey. Would be nice if companies give yubikeys to their employees, right?
Creating a key
Simple as following the prompt that appears after typing the command. If you don't know what to fill, use the default values.
And check the generatd key
Initializing gopass
Easy as typing
This will set up some stuff and will create the default store.
I recommend adding the autocomplete to your terminal
Using gopass
Gopass works in a "unix" like way. You'll have a tree (folders) where the leaves are encrypted files.
Let's begin by inserting a secret.
It will show a prompt and you'll have to fill the password twice.
The structure I follow is this (most of them optional)
{store}/{org}/{env}/{username or email}
.
Now let's list our secret, by simply doing
We should now see, something like this.
gopass ├── my-company │ └── pepe@my-company.com └── personal ├── pepe@personal.com └── twitter └── santiwilly
Perfect!
Let's continue. I'm just gonna throw you the commands, they don't have any complexity.
Show password
Copy password to clipboard
Generate random pass
Search secrets
Using stores
Here's were my journey got a bit complicated, as I mentioned the docs are not necessary bad, but you can get lost, maybe the website could be organized a bit better. So I ended up creating multiple docker containers and started playing around.
Stores (AKA mounts) let you group your passwords.
Example: personal
, company
.
Each one can live in a different repository, and you could potentially,
share company
with your peers.
Initialize new store
Creates a new store located at ~/.password-store-my-company
.
Add git remote to store
Clone existing store
Let's say you move to another computer, now it's where gopass starts to shine. Whether you use the same private key (imported in different computers) or you choose to have a key per machine, to clone a repo, you just need access to it.
It's important to specify gitcli
as the sync
method. Otherwise gopass
won't know how to synchronize the secret (it will use noop
by default).
Gopass provides other sync methods but I haven't checked them.
Solutions that provide a free private repo are:
Removing existing store
To avoid having issues with gopass, first we need to unmount the store.
Now that we've done this, it's safe to remove the folder.
Synchronization
In gopass, sync usually means git pull
and git push
, maybe also commit
but I'm not sure. Usually the commits are done on gopass insert
.
Synchronize with git remotes
Synchronzing a single store
Team sharing
We are finally on the last and most fantastic part, sharing secrets with people.
Suppose we have a colleague with an email logan@pm.me
. This person has
already generated a gpg key, for that email, in they machine.
Logan then, must export the public key and send it to us.
It's okay, public keys can be shared in untrusted environments. If you are still not convinced, try send from firefox. Keep in mind that people share their public keys in keyservers, like opengpgkeyserver.
Adding public key into gopass
We have the public key, now it's time to import it into our local gpg keyring.
And lastly, we need to add the new key to a gopass store.
You'll see a prompt with all of your stores. Choose the one you want, and it will re-encrypt your secrets with the new public key (plus the existing ones).
And that's it, we are done. You can of course remove recipients, but I'll let
you do the search, tip: gopass recipients --help
.
Conclusion
I have created a gopass cheat sheet with these commands and a presentation to convince your colleagues.
Gopass is an awesome tool to include in your toolbelt. Unfortunately, it is not that easy for non-developers, but still possible.
Some extra tools I use to enhance my gopass experience are:
I suggest installing it using F-droid, you'll need OpenKey-chain to create a new gpg key, and you already know how to add multiple recipients to your stores.
Browser extension for Firefox or Chrome that let's you access your stores.
Electron based UI wrapper for your gopass on the command line. It makes your life easier by providing a rich graphical user interface to search and manage your secrets.
Any feedback is welcome, as I'm no security expert and I'd be glad to have a better and more secure workflow.
Thank you for reading.
Note: I've added some random memes to ease the reading.