@ratelkey/cli 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +110 -0
- package/bin/ratel +54 -0
- package/package.json +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# RatelKey CLI
|
|
2
|
+
|
|
3
|
+
`ratel` enrols machines into a [RatelKey](https://ratelkey.com) Burrow and reads secrets from it.
|
|
4
|
+
|
|
5
|
+
A Burrow is a secrets manager you host. This CLI is how a machine joins one and how scripts on that machine read what they are allowed to read.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install -g @ratelkey/cli
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The published binary is a static Go executable. npm installs the one matching your platform and skips the rest. Linux (x64, arm64, arm), macOS (x64, Apple silicon) and Windows (x64, arm64) are supported.
|
|
14
|
+
|
|
15
|
+
To run it once without installing:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npx @ratelkey/cli <command>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Enrol a machine
|
|
22
|
+
|
|
23
|
+
On your Burrow's **Machines** page, click the **(+)** in the table header, name the machine, and choose **Create token**. Run the command it gives you on the machine you are enrolling:
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
npx @ratelkey/cli machine bootstrap <code>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Where the Burrow is reachable from more than one address, the dialog shows a command for **On your network** and one for **Outside your network**. Use the one that matches where the machine sits.
|
|
30
|
+
|
|
31
|
+
The keypair is generated on that machine. Only the public half is sent to the Burrow; the private key stays on disk and is what every later request is signed with.
|
|
32
|
+
|
|
33
|
+
The token is one-time and enrols a single machine.
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
Registered web-01 to my-burrow.
|
|
37
|
+
Machine 4f9c2a10-7b3e-4d51-9a6c-2e8f10b4d773
|
|
38
|
+
Identity /home/you/.burrow/burrows/burrow-a1b2c3d4e5f60718
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Read a secret
|
|
42
|
+
|
|
43
|
+
The value prints alone on stdout, so it drops straight into a shell variable:
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
export DATABASE_URL=$(ratel secret get myapp/prod/DATABASE_URL)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Set a default environment and bare names resolve against it:
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
ratel environment set myapp/prod
|
|
53
|
+
ratel secret get DATABASE_URL
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
`RATEL_ENV` overrides the saved default for one invocation:
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
RATEL_ENV=myapp/staging ratel secret get DATABASE_URL
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
A structured secret prints as JSON, so it pipes into `jq`:
|
|
63
|
+
|
|
64
|
+
```sh
|
|
65
|
+
ratel secret get myapp/prod/STRIPE | jq -r .publishable_key
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Passing a field name selects one field directly:
|
|
69
|
+
|
|
70
|
+
```sh
|
|
71
|
+
ratel secret get myapp/prod/STRIPE publishable_key
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Commands
|
|
75
|
+
|
|
76
|
+
| Command | What it does |
|
|
77
|
+
| --- | --- |
|
|
78
|
+
| `ratel machine bootstrap <code>` | Enrol this machine into a Burrow |
|
|
79
|
+
| `ratel secret get <project/env/NAME \| NAME> [field]` | Read a secret's current value |
|
|
80
|
+
| `ratel secret list` | List every secret this machine can read, by slug |
|
|
81
|
+
| `ratel project list` | List the projects this machine can read, and its access in each |
|
|
82
|
+
| `ratel environment set <project/env>` | Set the default environment for bare-name reads |
|
|
83
|
+
| `ratel environment show` | Show the default environment |
|
|
84
|
+
| `ratel whoami` | Show the machine identity and Burrow this CLI acts as |
|
|
85
|
+
| `ratel burrow list` | List the Burrow identities bootstrapped on this machine |
|
|
86
|
+
| `ratel version` | Print the version |
|
|
87
|
+
|
|
88
|
+
`ratel secret list` prints one slug per line, so it filters:
|
|
89
|
+
|
|
90
|
+
```sh
|
|
91
|
+
ratel secret list | grep prod
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Several Burrows on one machine
|
|
95
|
+
|
|
96
|
+
Bootstrapped identities live under `~/.burrow/burrows/<slug>/`. With one on file it is used automatically. With several, name the one you mean. `--burrow` belongs to the subcommand, so it goes after it and before the positional arguments:
|
|
97
|
+
|
|
98
|
+
```sh
|
|
99
|
+
ratel secret get --burrow my-burrow myapp/prod/DATABASE_URL
|
|
100
|
+
ratel whoami --burrow my-burrow
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
`RATEL_BURROW` sets it for the session. The selector accepts a name, a machine id, or the Burrow's URL.
|
|
104
|
+
|
|
105
|
+
## Links
|
|
106
|
+
|
|
107
|
+
- [ratelkey.com](https://ratelkey.com)
|
|
108
|
+
- [github.com/RatelKeyOrg/ratel-cli](https://github.com/RatelKeyOrg/ratel-cli)
|
|
109
|
+
|
|
110
|
+
MIT licensed.
|
package/bin/ratel
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// Picks the binary for this platform and hands the process over to it.
|
|
4
|
+
//
|
|
5
|
+
// The real CLI is a Go binary; npm is only how it gets onto the machine. Each platform binary is its own
|
|
6
|
+
// package declaring `os` and `cpu`, so npm installs exactly one and the rest are skipped as unmet optional
|
|
7
|
+
// dependencies — which is why they are optionalDependencies rather than dependencies.
|
|
8
|
+
|
|
9
|
+
const { spawnSync } = require('child_process');
|
|
10
|
+
const os = require('os');
|
|
11
|
+
|
|
12
|
+
const platformKey = `${os.platform()}-${os.arch()}`;
|
|
13
|
+
|
|
14
|
+
const packages = {
|
|
15
|
+
'linux-x64': '@ratelkey/cli-linux-x64/ratel',
|
|
16
|
+
'linux-arm64': '@ratelkey/cli-linux-arm64/ratel',
|
|
17
|
+
'linux-arm': '@ratelkey/cli-linux-arm/ratel',
|
|
18
|
+
'darwin-x64': '@ratelkey/cli-darwin-x64/ratel',
|
|
19
|
+
'darwin-arm64': '@ratelkey/cli-darwin-arm64/ratel',
|
|
20
|
+
'win32-x64': '@ratelkey/cli-win32-x64/ratel.exe',
|
|
21
|
+
'win32-arm64': '@ratelkey/cli-win32-arm64/ratel.exe',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const binary = packages[platformKey];
|
|
25
|
+
if (!binary) {
|
|
26
|
+
console.error(`ratel: unsupported platform ${platformKey}`);
|
|
27
|
+
console.error(`Supported: ${Object.keys(packages).join(', ')}`);
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let resolved;
|
|
32
|
+
try {
|
|
33
|
+
resolved = require.resolve(binary);
|
|
34
|
+
} catch {
|
|
35
|
+
// Name the package that is missing. It is an optionalDependency, so npm skips it in silence when it
|
|
36
|
+
// cannot be installed, and the first sign is this failure — at which point "could not find the binary"
|
|
37
|
+
// sends people looking in the wrong place.
|
|
38
|
+
const platformPackage = binary.slice(0, binary.lastIndexOf('/'));
|
|
39
|
+
console.error(`ratel: ${platformPackage} is not installed, so there is no binary for ${platformKey}.`);
|
|
40
|
+
console.error('It installs automatically with this package. If it did not, reinstall:');
|
|
41
|
+
console.error(' npm install -g @ratelkey/cli');
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// spawnSync, not execFileSync: execFileSync throws on a non-zero exit, which turns every ordinary CLI
|
|
46
|
+
// failure into a Node stack trace on top of the CLI's own message. This forwards the exit code and stays
|
|
47
|
+
// out of the way. A signal death (Ctrl-C) reports as 130 rather than 0, so a cancelled run doesn't look
|
|
48
|
+
// like a successful one to a script.
|
|
49
|
+
const result = spawnSync(resolved, process.argv.slice(2), { stdio: 'inherit' });
|
|
50
|
+
if (result.error) {
|
|
51
|
+
console.error(`ratel: could not run ${resolved}: ${result.error.message}`);
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
process.exit(result.status ?? 130);
|
package/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"@ratelkey/cli","version":"1.0.1","description":"RatelKey CLI — enrol machines into a Burrow and read its secrets","keywords":["secrets","vault","encryption","cli","ratelkey","burrow","self-hosted"],"homepage":"https://ratelkey.com","repository":{"type":"git","url":"git+https://github.com/RatelKeyOrg/ratel-cli.git"},"bugs":{"url":"https://github.com/RatelKeyOrg/ratel-cli/issues"},"license":"MIT","bin":{"ratel":"bin/ratel"},"files":["bin"],"optionalDependencies":{"@ratelkey/cli-linux-x64":"1.0.1","@ratelkey/cli-linux-arm64":"1.0.1","@ratelkey/cli-linux-arm":"1.0.1","@ratelkey/cli-darwin-x64":"1.0.1","@ratelkey/cli-darwin-arm64":"1.0.1","@ratelkey/cli-win32-x64":"1.0.1","@ratelkey/cli-win32-arm64":"1.0.1"}}
|