The CLI is designed for a variety of applications, ranging from local secret management to CI/CD and production scenarios.
The distinguishing factor, however, is the authentication method used.
To use the Infisical CLI in your local development environment, simply run the command below and follow the interactive guide.
Copy
infisical login
If you are in a containerized environment such as WSL 2 or Codespaces, run infisical login -i to avoid browser based login
# navigate to your projectcd /path/to/project# initialize infisicalinfisical init
This will create .infisical.json file at the location the command was executed. This file contains your local project settings. It does not contain any sensitive data.
To use the Infisical CLI in your local development environment, simply run the command below and follow the interactive guide.
Copy
infisical login
If you are in a containerized environment such as WSL 2 or Codespaces, run infisical login -i to avoid browser based login
# navigate to your projectcd /path/to/project# initialize infisicalinfisical init
This will create .infisical.json file at the location the command was executed. This file contains your local project settings. It does not contain any sensitive data.
To use Infisical for non local development scenarios, please create a service token. The service token will allow you to authenticate and interact with Infisical.
Once you have created a service token with the required permissions, you’ll need to feed the token to the CLI.
infisical run --env=dev --path=/apps/firefly -- [your application start command]# example with node (nodemon)infisical run --env=staging --path=/apps/spotify -- nodemon index.js# example with flaskinfisical run --env=prod --path=/apps/backend -- flask run# example with spring boot - maveninfisical run --env=dev --path=/apps/ -- ./mvnw spring-boot:run --quiet
Copy
infisical run --env=dev --path=/apps/firefly -- [your application start command]# example with node (nodemon)infisical run --env=staging --path=/apps/spotify -- nodemon index.js# example with flaskinfisical run --env=prod --path=/apps/backend -- flask run# example with spring boot - maveninfisical run --env=dev --path=/apps/ -- ./mvnw spring-boot:run --quiet
Custom aliases can utilize secrets from Infisical. Suppose there is a custom alias yd in custom.sh that runs yarn dev and needs the secrets provided by Infisical.
Copy
#!/bin/shyd() { yarn dev}
To make the secrets available from Infisical to yd, you can run the following command:
Copy
infisical run --env=prod --path=/apps/reddit --command="source custom.sh && yd"
The CLI is set to connect to Infisical Cloud by default, but if you’re running your own instance of Infisical, you can direct the CLI to it using one of the methods provided below.
Beginning with CLI version V0.4.0, it is now possible to choose between logging in through the Infisical cloud or your own self-hosted instance. Simply execute the infisical login command and follow the on-screen instructions.
# Set backend host setx INFISICAL_API_URL "https://your-self-hosted-infisical.com/api"# Remove backend host setx INFISICAL_API_URL ""# NOTE: Once set or removed, please restart powershell for the change to take effect
Your terminal keeps a history with the commands you run. When you create Infisical secrets directly from your terminal, they’ll stay there for a while.
For security and privacy concerns, we recommend you to configure your terminal to ignore those specific Infisical commands.
$HOME/.profile is pretty common but, you could place it under $HOME/.profile.d/infisical.sh or any profile file run at login