Marco Ricci commited on 2025-12-25 16:51:03
Zeige 2 geänderte Dateien mit 77 Einfügungen und 62 Löschungen.
| ... | ... |
@@ -19,8 +19,8 @@ |
| 19 | 19 |
|
| 20 | 20 |
Assuming the prerequisites are satisfied, ensure that the SSH agent is |
| 21 | 21 |
running, the SSH key is loaded into the agent, and the `SSH_AUTH_SOCK` |
| 22 |
-environment variable is correctly set up. The exact commands depend on |
|
| 23 |
-the SSH agent in use. |
|
| 22 |
+environment variable is correctly set up. |
|
| 23 |
+The exact commands depend on the SSH agent in use. |
|
| 24 | 24 |
|
| 25 | 25 |
=== "OpenSSH" |
| 26 | 26 |
|
| ... | ... |
@@ -49,8 +49,9 @@ the SSH agent in use. |
| 49 | 49 |
Enter passphrase to load key 'vault key': |
| 50 | 50 |
~~~~ |
| 51 | 51 |
|
| 52 |
- (Your key filename and key comment will likely differ. The agent |
|
| 53 |
- should automatically shut down once this terminal session is over.) |
|
| 52 |
+ (Your key filename and key comment will likely differ. |
|
| 53 |
+ The agent should automatically shut down once this terminal session |
|
| 54 |
+ is over.) |
|
| 54 | 55 |
|
| 55 | 56 |
=== "GnuPG" |
| 56 | 57 |
|
| ... | ... |
@@ -11,8 +11,9 @@ Using `derivepassphrase vault` with an SSH key requires: |
| 11 | 11 |
|
| 12 | 12 |
SSH agents are usually packaged as part of SSH client distributions. |
| 13 | 13 |
`ssh-agent` from [OpenSSH][] and Pageant from [PuTTY][] are known to |
| 14 |
-work. `gpg-agent` (v2) from [GnuPG][] is also known to work, but comes |
|
| 15 |
-with caveats; see notes below. |
|
| 14 |
+work. |
|
| 15 |
+`gpg-agent` (v2) from [GnuPG][] is also known to work, but comes with |
|
| 16 |
+caveats; see notes below. |
|
| 16 | 17 |
|
| 17 | 18 |
If in doubt, we recommend OpenSSH because it is the <i>de-facto</i> |
| 18 | 19 |
canonical SSH agent implementation. |
| ... | ... |
@@ -20,9 +21,11 @@ canonical SSH agent implementation. |
| 20 | 21 |
!!! note "Agent-specific features" |
| 21 | 22 |
|
| 22 | 23 |
* OpenSSH's `ssh-agent` supports limiting the time the agent holds |
| 23 |
- the key in memory ("key lifetime"). We recommend its usage.
|
|
| 24 |
+ the key in memory ("key lifetime").
|
|
| 25 |
+ We recommend its usage. |
|
| 24 | 26 |
* `ssh-agent` and GnuPG's `gpg-agent` support requiring confirmation |
| 25 |
- upon each use for a specific key. We recommend its usage as well. |
|
| 27 |
+ upon each use for a specific key. |
|
| 28 |
+ We recommend its usage as well. |
|
| 26 | 29 |
|
| 27 | 30 |
<section markdown id=agent-specific-notes> |
| 28 | 31 |
|
| ... | ... |
@@ -31,25 +34,27 @@ canonical SSH agent implementation. |
| 31 | 34 |
=== "GnuPG/`gpg-agent`" |
| 32 | 35 |
|
| 33 | 36 |
* `gpg-agent` v2.0 and later uses a *persistent* database of |
| 34 |
- known keys, SSH or otherwise. "Adding" a key to the agent |
|
| 35 |
- actually means *importing* it, and requires choosing an |
|
| 36 |
- "import passphrase" to protect the key on disk, in the |
|
| 37 |
- persistent database. `gpg-agent` will cache the import |
|
| 38 |
- passphrase in memory, and if that cache entry expires, then |
|
| 39 |
- the *import passphrase* must be provided to unlock the key. |
|
| 37 |
+ known keys, SSH or otherwise. |
|
| 38 |
+ "Adding" a key to the agent actually means *importing* it, and |
|
| 39 |
+ requires choosing an "import passphrase" to protect the key on |
|
| 40 |
+ disk, in the persistent database. |
|
| 41 |
+ `gpg-agent` will cache the import passphrase in memory, and if |
|
| 42 |
+ that cache entry expires, then the *import passphrase* must be |
|
| 43 |
+ provided to unlock the key. |
|
| 40 | 44 |
|
| 41 | 45 |
* The GnuPG distribution does not contain tools to generate |
| 42 | 46 |
native SSH keys or interactively add keys to a running |
| 43 | 47 |
`gpg-agent`, because its purpose is to expose keys in |
| 44 | 48 |
a different format (OpenPGP) to other (agent-compatible) SSH |
| 45 |
- clients. A third-party tool (such as a full SSH client |
|
| 46 |
- distribution) is necessary to load/import native SSH keys into |
|
| 47 |
- `gpg-agent`. |
|
| 49 |
+ clients. |
|
| 50 |
+ A third-party tool (such as a full SSH client distribution) is |
|
| 51 |
+ necessary to load/import native SSH keys into `gpg-agent`. |
|
| 48 | 52 |
|
| 49 | 53 |
* As a design consequence of the persistent database, |
| 50 | 54 |
`gpg-agent` always lists all known SSH keys as available in |
| 51 |
- the agent. It is impossible to remove an SSH key from |
|
| 52 |
- `gpg-agent` using standard SSH agent operations. |
|
| 55 |
+ the agent. |
|
| 56 |
+ It is impossible to remove an SSH key from `gpg-agent` using |
|
| 57 |
+ standard SSH agent operations. |
|
| 53 | 58 |
|
| 54 | 59 |
* `gpg-agent` does not advertise its communication socket by |
| 55 | 60 |
default, contrary to other SSH agents, so it must be manually |
| ... | ... |
@@ -67,29 +72,30 @@ canonical SSH agent implementation. |
| 67 | 72 |
`gpg-agent` on Windows contains a native emulation of |
| 68 | 73 |
UNIX domain sockets by the `assuan` library, which GnuPG |
| 69 | 74 |
internally uses for network connectivity and |
| 70 |
- inter-process communication. No specific configuration |
|
| 71 |
- is necessary, and the agent address can be directly |
|
| 72 |
- obtained with `gpgconf`: |
|
| 75 |
+ inter-process communication. |
|
| 76 |
+ No specific configuration is necessary, and the agent |
|
| 77 |
+ address can be directly obtained with `gpgconf`: |
|
| 73 | 78 |
|
| 74 | 79 |
~~~~ console |
| 75 | 80 |
$ gpgconf --list-dirs agent-ssh-socket |
| 76 | 81 |
~~~~ |
| 77 | 82 |
|
| 78 |
- This mode, sadly, is not currently supported. The |
|
| 79 |
- system is specific to GnuPG/`libassuan`, and unlikely to |
|
| 80 |
- be deployed widely enough to make implementing this |
|
| 81 |
- a priority for us… at least, relative to the other, more |
|
| 82 |
- common interprocess communication channels for SSH |
|
| 83 |
- agents on Windows. |
|
| 83 |
+ This mode, sadly, is not currently supported. |
|
| 84 |
+ The system is specific to GnuPG/`libassuan`, and |
|
| 85 |
+ unlikely to be deployed widely enough to make |
|
| 86 |
+ implementing this a priority for us… at least, relative |
|
| 87 |
+ to the other, more common interprocess communication |
|
| 88 |
+ channels for SSH agents on Windows. |
|
| 84 | 89 |
|
| 85 | 90 |
=== "Windows (OpenSSH emulation)" |
| 86 | 91 |
|
| 87 | 92 |
From v2.4 onwards, `gpg-agent` supports masquerading as |
| 88 | 93 |
OpenSSH's `ssh-agent` on Windows, by starting the agent |
| 89 | 94 |
with the `--enable-win32-openssh-support` command-line |
| 90 |
- argument. (Usually, this would be added to the |
|
| 91 |
- `gpg-agent` configuration file instead of being manually |
|
| 92 |
- supplied on the command-line.) |
|
| 95 |
+ argument. |
|
| 96 |
+ (Usually, this would be added to the `gpg-agent` |
|
| 97 |
+ configuration file instead of being manually supplied on |
|
| 98 |
+ the command-line.) |
|
| 93 | 99 |
|
| 94 | 100 |
[This mode, sadly, is not currently |
| 95 | 101 |
supported.](#python-support) |
| ... | ... |
@@ -105,29 +111,32 @@ canonical SSH agent implementation. |
| 105 | 111 |
|
| 106 | 112 |
The two major SSH agents on Windows (PuTTY/Pageant and OpenSSH) use |
| 107 | 113 |
<i>Windows named pipes</i> for communication, and Python on Windows |
| 108 |
- does not inherently support named pipes. Since no comprehensive |
|
| 109 |
- third-party Python modules to interface with named pipes appear to |
|
| 110 |
- exist, teaching `derivepassphrase` to use Windows named pipes |
|
| 111 |
- requires us developers to write the code to interface the Windows |
|
| 112 |
- system libraries ourselves. Development on this started after the |
|
| 113 |
- release of version 0.5, but since this is not our area of expertise, |
|
| 114 |
- and because the pre-0.5 design hard-codes the UNIX style of looking |
|
| 115 |
- up and connecting to an SSH agent, development progress on this |
|
| 116 |
- front has been much slower than usual. |
|
| 114 |
+ does not inherently support named pipes. |
|
| 115 |
+ Since no comprehensive third-party Python modules to interface with |
|
| 116 |
+ named pipes appear to exist, teaching `derivepassphrase` to use |
|
| 117 |
+ Windows named pipes requires us developers to write the code to |
|
| 118 |
+ interface the Windows system libraries ourselves. |
|
| 119 |
+ Development on this started after the release of version 0.5, but |
|
| 120 |
+ since this is not our area of expertise, and because the pre-0.5 |
|
| 121 |
+ design hard-codes the UNIX style of looking up and connecting to an |
|
| 122 |
+ SSH agent, development progress on this front has been much slower |
|
| 123 |
+ than usual. |
|
| 117 | 124 |
|
| 118 | 125 |
On non-Windows operating systems, the SSH agent is expected to advertise |
| 119 | 126 |
its communication socket via the `SSH_AUTH_SOCK` environment variable, |
| 120 |
-which is common procedure. Therefore, [your Python installation must |
|
| 121 |
-support UNIX domain sockets][socket.AF_UNIX]. |
|
| 127 |
+which is common procedure. |
|
| 128 |
+Therefore, [your Python installation must support UNIX domain |
|
| 129 |
+sockets][socket.AF_UNIX]. |
|
| 122 | 130 |
|
| 123 | 131 |
`derivepassphrase vault --version` will report on supported and on |
| 124 | 132 |
unavailable features, including "master SSH key":[^1] |
| 125 | 133 |
|
| 126 | 134 |
[^1]: This indicates support in principle, on this |
| 127 | 135 |
hardware/software/system combination, for interfacing with an SSH |
| 128 |
- agent. At runtime, this could still fail, e.g. because the SSH |
|
| 129 |
- agent isn't actually running, because `derivepassphrase` is trying |
|
| 130 |
- to connect to the wrong address, etc. |
|
| 136 |
+ agent. |
|
| 137 |
+ At runtime, this could still fail, e.g. because the SSH agent isn't |
|
| 138 |
+ actually running, because `derivepassphrase` is trying to connect to |
|
| 139 |
+ the wrong address, etc. |
|
| 131 | 140 |
|
| 132 | 141 |
=== "supported" |
| 133 | 142 |
|
| ... | ... |
@@ -155,9 +164,10 @@ unavailable features, including "master SSH key":[^1] |
| 155 | 164 |
|
| 156 | 165 |
For an SSH key to be usable by `derivepassphrase`, the SSH agent must |
| 157 | 166 |
always generate the same signature for the same input, i.e. the |
| 158 |
-signature must be deterministic for this key type. Commonly used SSH |
|
| 159 |
-key types (as of August 2025) include [ECDSA][], [Ed25519][], [RSA][], |
|
| 160 |
-and, somewhat less commonly, [Ed448][] and [DSA][]. |
|
| 167 |
+signature must be deterministic for this key type. |
|
| 168 |
+Commonly used SSH key types (as of August 2025) include [ECDSA][], |
|
| 169 |
+[Ed25519][], [RSA][], and, somewhat less commonly, [Ed448][] and |
|
| 170 |
+[DSA][]. |
|
| 161 | 171 |
|
| 162 | 172 |
[RSA]: https://en.wikipedia.org/wiki/RSA_(cryptosystem) |
| 163 | 173 |
[DSA]: https://en.wikipedia.org/wiki/Digital_Signature_Algorithm |
| ... | ... |
@@ -172,22 +182,24 @@ and, somewhat less commonly, [Ed448][] and [DSA][]. |
| 172 | 182 |
* DSA and ECDSA signatures require choosing a value specific to each |
| 173 | 183 |
signature (a "cryptographic nonce"), which must be unpredictable. |
| 174 | 184 |
Typical DSA/ECDSA implementations therefore generate a suitably large |
| 175 |
- random number as the nonce. This makes signatures non-deterministic, |
|
| 176 |
- and thus unsuitable for `derivepassphrase`. |
|
| 185 |
+ random number as the nonce. |
|
| 186 |
+ This makes signatures non-deterministic, and thus unsuitable for |
|
| 187 |
+ `derivepassphrase`. |
|
| 177 | 188 |
|
| 178 | 189 |
??? info "Exception: PuTTY/Pageant and RFC 6979" |
| 179 | 190 |
|
| 180 | 191 |
[RFC 6979][] specifies a method to *calculate* the nonce from |
| 181 |
- the DSA/ECDSA key and the message to be signed. DSA/ECDSA |
|
| 182 |
- signatures from SSH agents implementing RFC 6979 are therefore |
|
| 183 |
- deterministic, and thus *also* suitable for `derivepassphrase`. |
|
| 192 |
+ the DSA/ECDSA key and the message to be signed. |
|
| 193 |
+ DSA/ECDSA signatures from SSH agents implementing RFC 6979 are |
|
| 194 |
+ therefore deterministic, and thus *also* suitable for |
|
| 195 |
+ `derivepassphrase`. |
|
| 184 | 196 |
Pageant 0.81 implements RFC 6979. |
| 185 | 197 |
|
| 186 | 198 |
!!! warning "Warning: Pageant < 0.81" |
| 187 | 199 |
|
| 188 | 200 |
Pageant 0.80 and earlier uses a different, homegrown method |
| 189 |
- to calculate the nonce deterministically. Those versions |
|
| 190 |
- are *also* prinicipally suitable for use with |
|
| 201 |
+ to calculate the nonce deterministically. |
|
| 202 |
+ Those versions are *also* prinicipally suitable for use with |
|
| 191 | 203 |
`derivepassphrase`, but **they generate different signatures |
| 192 | 204 |
-- and different derived passphrases -- than Pageant 0.81 |
| 193 | 205 |
and later**. |
| ... | ... |
@@ -209,8 +221,9 @@ and, somewhat less commonly, [Ed448][] and [DSA][]. |
| 209 | 221 |
|
| 210 | 222 |
If you do not yet have a (supported) SSH key, we recommend Ed25519 for |
| 211 | 223 |
maximum speed and reasonable availability, otherwise RSA for maximum |
| 212 |
-availability. We do not in general recommend Ed448 because it is not |
|
| 213 |
-widely implemented (as of August 2025). |
|
| 224 |
+availability. |
|
| 225 |
+We do not in general recommend Ed448 because it is not widely |
|
| 226 |
+implemented (as of August 2025). |
|
| 214 | 227 |
|
| 215 | 228 |
??? example "Generating new SSH keys for `derivepassphrase`" |
| 216 | 229 |
|
| ... | ... |
@@ -262,15 +275,16 @@ widely implemented (as of August 2025). |
| 262 | 275 |
|
| 263 | 276 |
=== "GnuPG" |
| 264 | 277 |
|
| 265 |
- Not supported natively. A different SSH client distribution |
|
| 266 |
- such as OpenSSH or PuTTY is necessary to create SSH keys |
|
| 267 |
- specifically. |
|
| 278 |
+ Not supported natively. |
|
| 279 |
+ A different SSH client distribution such as OpenSSH or PuTTY is |
|
| 280 |
+ necessary to create SSH keys specifically. |
|
| 268 | 281 |
|
| 269 | 282 |
Alternatively, GnuPG supports reusing keys in its native OpenPGP |
| 270 | 283 |
format for SSH as long as the underlying key type is compatible. |
| 271 | 284 |
First, obtain GnuPG's internal identifier (the "keygrip") for |
| 272 |
- the correct key you may want to use. (Warning: OpenPGP subkeys |
|
| 273 |
- have a different keygrip, so be sure to use the correct one.) |
|
| 285 |
+ the correct key you may want to use. |
|
| 286 |
+ (Warning: OpenPGP subkeys have a different keygrip, so be sure |
|
| 287 |
+ to use the correct one.) |
|
| 274 | 288 |
|
| 275 | 289 |
~~~~ console |
| 276 | 290 |
$ gpg --list-keys --with-keygrip sample-key@example.com |
| 277 | 291 |