guide.deuxfleurs.fr/content/operations/acces/pass.md

172 lines
4.6 KiB
Markdown
Raw Normal View History

2022-05-12 14:51:09 +00:00
+++
title = "Le dépôt des secrets"
description = "Le dépôt des secrets"
weight = 10
2022-05-12 14:51:09 +00:00
+++
We use [pass, 'the standard unix password manager'](https://www.passwordstore.org/), to manage our key store securely at Deuxfleurs. Getting access to our production involves publishing one's GPG key (through Gitea) and importing/verifying/signing every other sysadmin's key, before setting up `pass`.
2022-10-16 08:55:44 +00:00
Our process was adapted from [this Medium article](https://medium.com/@davidpiegza/using-pass-in-a-team-1aa7adf36592) — thanks, David!
## You are new and want to access the secrets repository
2022-10-16 08:55:44 +00:00
You need a GPG key to start with.
If you do not already have one, you can generate a new one with:
2022-10-16 08:55:44 +00:00
```bash
gpg2 --expert --full-gen-key
# Personnaly I use `9) ECC and ECC`, `1) Curve 25519`, and `5y`
```
In any case, you need to export your public key. Upload the output (public key) of the following command to [your Gitea account](https://git.deuxfleurs.fr/user/settings/keys).
2022-10-16 08:55:44 +00:00
```bash
gpg2 --export --armor <your email address>
```
It is now publicly accessible at `https://git.deuxfleurs.fr/<your_gitea_username>.gpg`
2022-10-16 08:55:44 +00:00
Inform all the other sysadmins that you have published your key for them to import/verify/sign it.
### Import/verify/sign every other sysadmin's key into your keychain
2022-10-16 08:55:44 +00:00
You now need to import and sign every other sysadmin's GPG key. For example, import Quentin's key to your keychain as follow:
2022-10-16 08:55:44 +00:00
```bash
gpg2 --import <(curl https://git.deuxfleurs.fr/quentin.gpg)
gpg2 --list-keys
# pub ed25519/0xE9602264D639FF68 2022-04-19 [SC] [expire : 2027-04-18]
# Empreinte de la clef = 8023 E27D F1BB D52C 559B 054C E960 2264 D639 FF68
# uid [ ultime ] Quentin Dufour <quentin@deuxfleurs.fr>
# sub cv25519/0xA40574404FF72851 2022-04-19 [E] [expire : 2027-04-18]
```
> How to read this snippet:
> - the key id: `E9602264D639FF68`
> - the key fingerprint: `8023 E27D F1BB D52C 559B 054C E960 2264 D639 FF68`
2022-10-16 08:55:44 +00:00
To perform the check, you need another communication channel (ideally physically, otherwise through the phone, Matrix if you already trusted the other person, or else). Compare the signature you read with the sysadmin's. If they match, you good.
2022-10-16 08:55:44 +00:00
Now that you have verified the key, sign it:
2022-10-16 08:55:44 +00:00
```bash
gpg --edit-key quentin@deuxfleurs.fr # by email
2022-10-16 08:55:44 +00:00
# or
gpg --edit-key E9602264D639FF68 # by key id
2022-10-16 08:55:44 +00:00
# gpg> lsign
# (say yes, maybe several times)
2022-10-16 08:55:44 +00:00
# gpg> save
```
Once you signed every sysadmin, ask a sysadmin to add your key to the secrets keystore. They will need to [Add a sysadmin](#add-a-sysadmin).
2022-10-16 08:55:44 +00:00
Now you are ready to install `pass`:
```bash
sudo apt-get install pass # Debian + Ubuntu
sudo yum install pass # Fedora + RHEL
sudo zypper in password-store # OpenSUSE
sudo emerge -av pass # Gentoo
sudo pacman -S pass # Arch Linux
brew install pass # macOS
pkg install password-store # FreeBSD
```
*Go to [passwordstore.org](https://www.passwordstore.org/) for more information about pass*.
Download the repository:
```
mkdir -p ~/.password-store
cd ~/.password-store
git clone git@git.deuxfleurs.fr:Deuxfleurs/secrets.git deuxfleurs
```
Finally check that everything works:
2022-10-16 08:55:44 +00:00
```bash
pass show deuxfleurs
```
If you see a listing, you settled!
2022-10-16 08:55:44 +00:00
---
---
## You are a sysadmin and want to operate the secrets repository
2022-10-16 08:55:44 +00:00
## Initialise the pass store
> These instructions are for _bootstrapping_ the pass store. **Don't do it on Deuxfleurs' secrets repository** (don't be like ADRN). You would override the existing sysadmins and generally have a bad time.
Generate a new password store named deuxfleurs for you:
2022-10-16 08:55:44 +00:00
```
pass init -p deuxfleurs you@example.com
```
Add a password in this store, it will be encrypted with your gpg key:
2022-10-16 08:55:44 +00:00
```bash
pass generate deuxfleurs/backup_nextcloud 20
# or
pass insert deuxfleurs/backup_nextcloud
```
## Add a sysadmin
2022-10-16 08:55:44 +00:00
Edit `~/.password-store/acme/.gpg-id` and add the id of the newbie:
2022-10-16 08:55:44 +00:00
```
alice@example.com
jane@example.com
bob@example.com
```
Make sure that you trust the keys of your new sysadmin:
2022-10-16 08:55:44 +00:00
```
$ gpg --edit-key jane@example.com
gpg> lsign
gpg> y
gpg> save
```
Now re-encrypt the secrets and push your modifications:
2022-10-16 08:55:44 +00:00
```
pass init -p deuxfleurs $(cat ~/.password-store/deuxfleurs/.gpg-id)
cd ~/.password-store/deuxfleurs
git commit
git push
2022-10-16 08:55:44 +00:00
```
They will now be able to decrypt any password:
2022-10-16 08:55:44 +00:00
```
pass deuxfleurs/backup_nextcloud
```
## Sharing with git
2022-10-16 08:55:44 +00:00
To create the repo _on bootstrap exclusively_:
2022-10-16 08:55:44 +00:00
```bash
cd ~/.password-store/deuxfleurs
git init
git add .
git commit -m "Initial commit"
# Set up remote
git push
```
To retrieve the repo:
2022-10-16 08:55:44 +00:00
```bash
mkdir -p ~/.password-store
2022-10-16 08:55:44 +00:00
cd ~/.password-store
git clone https://git.example.com/org/repo.git deuxfleurs
```