Deploy with a private key

Run your encrypted .env file on a server.
← Back to Quickstart

Deploy your code and encrypted .env file to your server, and install the Dotenvx CLI there. Keep .env.keys on your local machine.

Find your private key with the keypair command.

$ dotenvx keypair
{"DOTENV_PUBLIC_KEY":"0220d830351410598be484f43a7b07097e09851f50426832876e8b5815a1752990","DOTENV_PRIVATE_KEY":"b37dbad0e00206f31486c4f44f8cc7abf2f1be96d5ba352eb791122b5e131bbf"}

Set it as DOTENV_PRIVATE_KEY on your production environment.

Run the same command on your server:

$ dotenvx run -- node index.js
⟐ injected env (2) from .env
Hello Secret

Dotenvx uses your private key to decrypt and inject your secrets just-in-time, but this time with the private key stored on your server.

Open page ↗

Side path