Skip to main content

Create

Make the key that encrypts the JetStream store.

The command writes 32 random bytes as hex to the file that nats.server.jetstream.key_file names, with mode 0600. It makes the directory of the file with mode 0700. The embedded NATS server reads the key when it starts, and encrypts each stream and bucket in store_dir.

The command refuses to write a file that exists, because a new key in place of the old key makes each stream unreadable. Keep a copy of the key apart from the backup of store_dir: without the key, the server cannot read the store. Refer to 2. NATS.

osapi nats key create

Examples​

osapi nats key create -f /etc/osapi/osapi.yaml

Result​

The command prints:

$ osapi nats key create -f /etc/osapi/osapi.yaml
JetStream key:
  Key file:  /etc/osapi/nats/jetstream.key

With --json, the command prints:

{
"key_file": "/etc/osapi/nats/jetstream.key"
}

Global flags​

FlagDescriptionDefault
-d, --debugEnable or disable debug mode
-j, --jsonEnable JSON output
-f, --osapi-filePath to config file; without one at the default path, osapi runs on the defaults/etc/osapi/osapi.yaml

Output tells how the result is printed, and what --json gives.