45eff8af9e70bed2b828f75111f5517bd9587db0
Marco Ricci Add a tutorial: setting up...

Marco Ricci authored 2 months ago

1) # Tutorial: setting up `derivepassphrase vault` for three accounts, with a master passphrase
2) 
3) ## The scenario
4) 
5) In this tutorial, we will setup `derivepassphrase` for three services, using a master passphrase and the standard `vault` passphrase derivation scheme.
6) We will assume the following three services with the following passphrase policies:
7) 
8) <div class="grid cards" markdown>
9) 
10) -   __email account__
11) 
12)     ---
13) 
14)     - between 12 and 20 characters
15)     - no spaces
16)     - 1 upper case letter, 1 lower case letter, 1 digit
Marco Ricci Implement feedback on the b...

Marco Ricci authored 2 months ago

17)     * no character may appear 3 times (or more) in a row
Marco Ricci Add a tutorial: setting up...

Marco Ricci authored 2 months ago

18) 
19) -   __bank account__
20) 
21)     ---
22) 
23)     - only digits
24)     * exactly 5 digits
25)     * an additional one-time password via a hardware token ("[two-factor authentication][2FA]")
26) 
27) -   __work account__
28) 
29)     ---
30) 
31)     - exactly 8 characters
32)     * no spaces
33)     - 1 special character, 1 letter, 1 digit
34)     - must be changed every quarter (January, April, July and October) to a different value ("passphrase rotation" or "rollover")
35)     - must actually be different from the previous *two* passphrases
36) 
37) </div>
38) 
39) [2FA]: https://en.wikipedia.org/wiki/Two-factor_authentication
40) 
41) ## Installing `derivepassphrase`
42) 
43) Install `pipx`:
44) 
45) ~~~~ shell-session
46) $ cd ~
47) $ python3 -m venv .venv
48) $ . .venv/bin/activate
49) $ pip install pipx
50) ~~~~
51) 
52) Install `derivepassphrase`:
53) 
54) ~~~~ shell-session
55) $ pipx install derivepassphrase
56) ~~~~
57) 
58) Check that the installation was successful.
59) 
60) ~~~~ shell-session
61) $ devirepassphrase --version
Marco Ricci Implement feedback on the b...

Marco Ricci authored 2 months ago

62) derivepassphrase, version 0.3.0
Marco Ricci Add a tutorial: setting up...

Marco Ricci authored 2 months ago

63) ~~~~
64) 
65) (…or similar output.)
66) 
67) ## Choosing a master passphrase
68) 
69) `derivepassphrase` uses a master passphrase `MP`, and derives all other passphrases `P` from `MP`.
70) We shall choose the master passphrase: `I am an insecure master passphrase, but easy to type.`
71) 
72) ## Setting up the email account
73) 
74) In `derivepassphrase`, each passphrase configuration contains a *service name*, which is how `derivepassphrase` distinguishes between configurations.
75) This service name can be chosen freely, but the resulting passphrase depends on the chosen service name.
76) For our email account, we choose the straightforward service name `email`.
77) 
78) We need to translate the passphrase policy into options for `derivepassphrase`:
79) 
Marco Ricci Use proper HTML for variabl...

Marco Ricci authored 2 months ago

80) - A policy "(at least) <var>n</var> lower case letters" translates to the option <code>-<span/>-lower <var>n</var></code>, for any <var>n</var> > 0.
Marco Ricci Implement feedback on the b...

Marco Ricci authored 2 months ago

81)   Upper case letters (`--upper`), digits (`--number`), symbols (`--symbol`), spaces (`--space`) and dashes (`--dash`) work similarly.
Marco Ricci Add a tutorial: setting up...

Marco Ricci authored 2 months ago

82) - A policy "spaces *forbidden*" translates to the option `--space 0`.
83)   Again, other character classes behave similarly.
Marco Ricci Use proper HTML for variabl...

Marco Ricci authored 2 months ago

84) - A policy "no character may appear <var>n</var> times (or more) in a row" translates to the option <code>-<span/>-repeat (<var>n</var> − 1)</code>, for any <var>n</var> > 1.
Marco Ricci Add a tutorial: setting up...

Marco Ricci authored 2 months ago

85)   In particular, `--repeat 1` means no character may be immediately repeated.
Marco Ricci Implement feedback on the b...

Marco Ricci authored 2 months ago

86)   (See the mnemonic below.)
Marco Ricci Use proper HTML for variabl...

Marco Ricci authored 2 months ago

87) * A policy "between <var>n</var> and <var>m</var> characters long" translates to <code>-<span/>-length <var>k</var></code>, for any choice of <var>k</var> which satisfies <var>n</var> ≤ <var>k</var> ≤ <var>m</var>.
88)   (`derivepassphrase` does not explicitly choose <var>k</var> for you.)
Marco Ricci Add a tutorial: setting up...

Marco Ricci authored 2 months ago

89) 
Marco Ricci Implement feedback on the b...

Marco Ricci authored 2 months ago

90) ??? note "Mnemonic: the `--repeat` option"
91) 
92)     The `--repeat` option denotes the *total* number of consecutive occurrences of the same character.
Marco Ricci Use proper HTML for variabl...

Marco Ricci authored 2 months ago

93)     Or alternatively: if you request <code>-<span/>-repeat <var>n</var></code>, then `derivepassphrase` will *avoid* deriving any passphrase that repeats a character *another <var>n</var> times*.
Marco Ricci Implement feedback on the b...

Marco Ricci authored 2 months ago

94) 
95)     Examples:
96) 
97)     | option        | valid examples         | invalid examples          |
98)     |:--------------|:-----------------------|:--------------------------|
99)     | `--repeat 1`  | `abc`, `aba`, `abcabc` | `aa`, `abba`, `ababb`     |
100)     | `--repeat 4`  | `122333111123`, `4444` | `55555`, `67788888999996` |
101)     | `--repeat 11` | `01234567899999999999` | `$$$$$$$$$$$$$$$$$$$$$$$` |
102) 
103) 
Marco Ricci Add a tutorial: setting up...

Marco Ricci authored 2 months ago

104) For the `email` service, we choose passphrase length 12.
105) This leads to the command-line options `--length 12 --space 0 --upper 1 --lower 1 --number 1 --repeat 3`.
106) Because we are using a master passphrase, we also need the `-p` option.
107) 
108) !!! note "Note: interactive input"
109) 
110)     In code listings, sections enclosed in `[[...]]` signify input to the program, for you to type or paste in.
111) 
112)     Also, it is normal for passphrase prompts to not "echo" the text you type in.
113) 
114) ~~~~ shell-session
115) $ derivepassphrase vault --length 12 --space 0 --upper 1 --lower 1 \
116) >                        --number 1 --repeat 3 -p email
117) Passphrase: [[I am an insecure master passphrase, but easy to type.]]
118) kEFwoD=C?@+7
119) ~~~~
120) 
121) By design, we can re-generate the same passphrase using the same input to `derivepassphrase`:
122) 
123) ~~~~ shell-session
124) $ derivepassphrase vault --length 12 --space 0 --upper 1 --lower 1 \
125) >                        --number 1 --repeat 3 -p email
126) Passphrase: [[I am an insecure master passphrase, but easy to type.]]
127) kEFwoD=C?@+7
128) ~~~~
129) 
130) We can then visit our email provider and change the passphrase to `kEFwoD=C?@+7`.
131) 
132) ### Storing the settings to disk
133) 
134) Because it is tedious to memorize and type in the correct settings to re-generate this passphrase, `derivepassphrase` can optionally store these settings, using the `--config` option.
135) 
136) ~~~~ shell-session
137) $ derivepassphrase vault --config --length 12 --space 0 --upper 1 --lower 1 \
138) >                        --number 1 --repeat 3 email
139) ~~~~
140) 
141) !!! warning "Warning: `-p` and `--config`"
142) 
143)     Do **not** use the `-p` and the `--config` options together to store the master passphrase!
Marco Ricci Implement feedback on the b...

Marco Ricci authored 2 months ago

144)     The configuration is assumed to *not contain sensitive contents* and is *not encrypted*, so your master passphrase is then visible to *anyone* with appropriate privileges!