- Local development
- Docker containers
- Staging, production & all other use cases
The steps below authenticate the CLI with your own account, link a codebase to an Infisical project, and inject the secrets you have access to into your local development process as environment variables.The prompt asks which instance you want to use. Select Infisical Cloud (US), Infisical Cloud (EU), or Self-hosted, then finish signing in through your browser.Select your organization and project when prompted. This creates an The CLI fetches the secrets you have access to and passes them to your application as environment variables. Your application reads them the same way it always has, through
For every available option, see the
If you prefer to learn by watching, follow along with our step-by-step video tutorial.
Step 1: Log in to Infisical
Authenticate the CLI with your Infisical account.On a machine with no browser, such as a remote SSH session, WSL 2, or Codespaces, run
infisical login -i to log in from the terminal instead.Step 2: Link your codebase to your project
Go to the directory of the codebase you’re working on and link it to your Infisical project..infisical.json file with your local project settings, so the commands you run next don’t need a project ID..infisical.json holds no secret values, so you can safely commit it to version control. Everyone who clones the repository is then pointed at the same project.Step 3: Start your application with secrets injected
Run your usual start command throughinfisical run, placing it after the -- separator.process.env in Node.js or os.environ in Python, so you don’t need to change any application code.By default, If you also need the secrets in that folder’s subfolders, add
infisical run only injects the secrets sitting at the root of the environment, so anything inside a folder is skipped. If your secrets live in folders, you can specify a folder to include using --path:--recursive:Injecting secrets into a shell function or alias
Injecting secrets into a shell function or alias
A start command that is a shell function or an alias can’t be called directly after Source the file and call the function in a single command:The
--, because it only exists inside your shell. Use the --command flag to run it in a shell instead.For example, if custom.sh defines a yd function that runs yarn dev:--command flag is also how you chain commands together, as in --command="npm run migrate && npm run dev".infisical run reference.For installation instructions, troubleshooting, and related local workflows such as personal overrides and secret scanning, see the local development guide.Starting with CLI version v0.4.0, you can now choose to log in via Infisical Cloud (US/EU) or your own self-hosted instance by simply running
infisical login and following the on-screen instructions — no need to manually set the INFISICAL_API_URL environment variable.For versions prior to v0.4.0, the CLI defaults to US Cloud. To connect to EU Cloud or a self-hosted instance, set the INFISICAL_API_URL environment variable to https://eu.infisical.com or your custom URL.History
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.Ignore commands
Ignore commands
- Unix/Linux
- Windows
FAQ
Can I connect the CLI to my self-hosted or non-US Cloud Infisical instance?
Can I connect the CLI to my self-hosted or non-US Cloud Infisical instance?
Yes. The CLI is set to connect to Infisical US Cloud by default, but if you’re using EU Cloud or a self-hosted instance you can configure the domain for all CLI commands.
Method 1: Use the updated CLI (v0.4.0+)
Beginning with CLI version V0.4.0, you can choose between logging in through Infisical US Cloud, EU Cloud, or your own self-hosted instance. Simply execute theinfisical login command and follow the on-screen instructions.Method 2: Export environment variable
You can point the CLI to the self-hosted Infisical instance by exporting the environment variableINFISICAL_DOMAIN in your terminal. (The legacy INFISICAL_API_URL variable still works.)- Linux/MacOs
- Windows Powershell
Method 3: Set manually on every command
If you prefer not to use an environment variable, you must include the--domain flag on every CLI command you run:Can I use the CLI with service tokens?
Can I use the CLI with service tokens?
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.
Pass via shell environment variable
The CLI is configured to look for an environment variable namedINFISICAL_TOKEN. If set, it’ll attempt to use it for authentication.