1
1
# syncrets
2
- A utility for synchronizing secrets between systems like
3
- [ Hashicorp vault] [ VAULT ] and formats like ejson/eyaml. Think of it like an
2
+ * WIP* : This project is a * WORK IN PROGRESS* , so consider it useful for
3
+ experimentation but not ready for production use. Use at your own risk
4
+ but if you * do* use it I would love to hear what you think so please
5
+ log issues for anything you would like to see fixed/improved.
6
+
7
+ syncrets is a little utility for synchronizing secrets between systems like
8
+ [ Hashicorp vault] [ VAULT ] and formats like [ ejson] [ EJSON ] . Think of it like an
4
9
_ rsync for secrets_ . Secrets need to be handled carefully and syncrets can
5
10
help transfer, list, export, and otherwise manage secrets between systems
6
- and formats.
11
+ and formats. The name ` syncrets ` is a portmanteau of ` secrets ` and ` sync ` ...
12
+ obligatory [ xkcd] [ XKCD-739 ] .
7
13
8
14
Here is a simple example of using syncrets to copy secrets between two
9
15
vault servers running locally:
10
16
```
11
- syncrets sync vault://localhost:8200 /secrets/ vault://localhost:8201 /secrets/
17
+ syncrets sync vault://vault-a /secrets/ vault://vault-b /secrets/
12
18
```
13
- * NOTE* : This project is a * WORK IN PROGRESS* , so consider it useful for
14
- experimentation but not ready for production use. Use at your own risk.
15
19
16
20
## syncrets config file
17
- Outside of test scenarios, it isn't likely that two instances of vault would
18
- be running on localhost. To make working with multiple vaults easier,
19
- syncrets supports a ` ~/.syncrets/syncrets.yml ` configuration file, for
20
- example:
21
+
22
+ To faciliate working with multiple vaults, syncrets looks for a ` syncrets.yml `
23
+ configuration file in the working directory as well as ` ~/.syncrets/syncrets.yml ` .
24
+ Here is an example:
25
+
21
26
```
22
27
vault:
23
28
vault-a:
@@ -34,17 +39,42 @@ vault:
34
39
file: ~/.syncrets/.vault-b-token
35
40
```
36
41
Using a configuration file allows you to refer to servers using the name
37
- (alias) present in their section of the configuration file.
42
+ (alias) present in their section of the configuration file, so you can
43
+ refer to ` vault://vault-a/secrets ` rather than ` http://localhost:8200/secrets ` .
38
44
39
- For example, using the configuration above we can now rewrite the
40
- previous syncrets example like so:
41
- ```
42
- syncrets sync vault://vault-a/secrets/foo/ vault://vault-b/secrets/bar/
43
- ```
44
- Using our configuration file syncrets will now know to reach ` vault-a ` using
45
+ This example configuration file configures syncrets to reach ` vault-a ` using
45
46
` http://localhost:8200 ` and to reach ` vault-b ` using ` http://localhost:8201 `
46
47
which saves you from having to type out the full scheme, hostname, and port
47
- when building URLs to pass to syncrets.
48
+ when building URLs to pass to syncrets. The configuration also tells syncrets to
49
+ load vault auth tokens from file (assuming that these tokens have been obtained
50
+ previously).
51
+
52
+ ## syncrets ejson
53
+
54
+ syncrets can directly ` sync ` secrets between two vault servers but can also
55
+ be used to ` sync ` secrets to a local file (preferrably in ejson format ...
56
+ these are _ secrets_ after all).
57
+
58
+ If the source or target of a syncrets ` sync ` ends with ` .ejson ` then
59
+ syncrets will use the ` ejson ` configuration section of ` syncrets.yml ` to
60
+ configure the default encryption public key to use:
61
+ ```
62
+ ejson:
63
+ public_key: a9d52487a1232e5c292a9680f4a44a84ea302ba05ff12d2e9d11662d20fc0139
64
+ ```
65
+
66
+ For both encryption and decryption syncrets assumes that the ejson ` EJSON_KEYDIR `
67
+ environment has been set if the ejson keys are not present in their default location.
68
+
69
+ * Example* :
70
+ ```
71
+ syncrets sync vault://vault-a/secret/ ./secrets.ejson
72
+ ```
73
+
74
+ Note: syncrets will write _ unencrypted_ secrets to files ending with ` .json ` but
75
+ this regular JSON format is included primarily for testing/debugging purposes and
76
+ shouldn't be used for anything that is sensitive if the underlying filesystem isn't
77
+ trustworthy.
48
78
49
79
## syncrets commands
50
80
### auth
@@ -75,5 +105,6 @@ syncrets rm vault://localhost:8200/secrets/
75
105
```
76
106
* CAUTION* : Use the ` rm ` command _ carefully_ , it can be a potent footgun.
77
107
78
-
79
108
[ VAULT ] : https://www.vaultproject.io/
109
+ [ EJSON ] : https://github.com/Shopify/ejson
110
+ [ XKCD-739 ] : https://xkcd.com/739/
0 commit comments