> ## Documentation Index
> Fetch the complete documentation index at: https://docs.endorlabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://docs.endorlabs.com/feedback

```json
{
  "path": "/developers-api/cli/install-and-configure/index",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

# Install and configure endorctl

> Learn how to install, configure, and authenticate with Endor Labs

Perform software composition analysis, dependency management, or detect secrets in your code using Endor Labs.

## Download and install endorctl

Use one of the following methods to download and install endorctl on your local system. After you install endorctl, you must authenticate. Then you can start scanning your code.

### Install endorctl with Homebrew

Use Homebrew to efficiently install endorctl on macOS and Linux operating systems making it easy to manage dependencies, and track installed packages with their versions.

Install endorctl from the [Endor Labs tap](https://github.com/endorlabs/homebrew-tap) with Homebrew by running the following commands. Endor Labs updates the tap regularly with the latest endorctl release.

```bash theme={null}
brew tap endorlabs/tap
brew install endorctl
```

### Install endorctl with npm

Use npm to efficiently install endorctl on macOS, Linux, and Windows operating systems making it easy to manage dependencies, track and update installed packages and their versions.

1. Make sure that you have npm installed in your local environment and use the following command to install endorctl.

   ```bash theme={null}
   npm install -g endorctl
   ```

2. Run the following command to get the npm global bin directory.

   ```bash theme={null}
   npm config get prefix
   ```

3. Edit your shell configuration file and insert the path you obtained from the previous command.

   ```bash theme={null}
   export PATH="/path/to/npm/global/bin:$PATH"
   ```

4. Reload your shell configuration and confirm that endorctl runs.

   ```bash theme={null}
   endorctl --version
   ```

5. To update your version of endorctl, run the following command.

   ```bash theme={null}
   npm update -g endorctl
   ```

[endorctl](https://www.npmjs.com/package/endorctl) is available as an npm package and Endor Labs updates it regularly with the latest endorctl release.

### Download and install the endorctl binary directly

To download the endorctl binary directly use the following commands:

<Tabs>
  <Tab title="Linux">
    ```bash theme={null}
    # Download the latest CLI for Linux amd64
    curl https://api.endorlabs.com/download/latest/endorctl_linux_amd64 -o endorctl

    # Verify the checksum of the binary
    echo "$(curl -s https://api.endorlabs.com/sha/latest/endorctl_linux_amd64)  endorctl" | sha256sum -c

    # Modify the permissions of the binary to ensure it is executable
    chmod +x ./endorctl

    # Create an alias endorctl of the binary to ensure it is available in other directory
    alias endorctl="$PWD/endorctl"
    ```
  </Tab>

  <Tab title="Mac OS">
    ```bash theme={null}
    # Download the latest CLI for MacOS ARM64
    curl https://api.endorlabs.com/download/latest/endorctl_macos_arm64 -o endorctl

    # Verify the checksum of the binary
    echo "$(curl -s https://api.endorlabs.com/sha/latest/endorctl_macos_arm64)  endorctl" | shasum -a 256 -c

    # Modify the permissions of the binary to ensure it is executable
    chmod +x ./endorctl

    # Create an alias endorctl of the binary to ensure it is available in other directory
    alias endorctl="$PWD/endorctl"
    ```
  </Tab>

  <Tab title="Windows">
    ```bash theme={null}
    # Download the latest CLI for Windows amd64
    curl -O https://api.endorlabs.com/download/latest/endorctl_windows_amd64.exe
    # Check the expected checksum of the binary file
    curl https://api.endorlabs.com/sha/latest/endorctl_windows_amd64.exe
    # Verify the expected checksum and the actual checksum of the binary match
    certutil -hashfile .\endorctl_windows_amd64.exe SHA256
    # Rename the binary file
    ren endorctl_windows_amd64.exe endorctl.exe
    ```
  </Tab>
</Tabs>

You can also view these instructions via the Endor Labs application user interface:

1. Sign in to Endor Labs.
2. Select **Projects** from the left sidebar.
3. Click **Add Project**.
4. Choose **CLI**.
5. Follow the on-screen instructions to download and install the appropriate version and architecture of `endorctl` for your system.

You can keep track of endorctl release details by checking the [Endor Labs release notes](/releasenotes).

## Authenticate to Endor Labs

You can authenticate to Endor Labs in the following ways:

1. [Using the init command](#login-with-the-init-command)
2. [With an API token](#login-with-an-api-key)

### Login with the init command

Run `endorctl init` and your browser window will open automatically. Select your authentication provider from the available options and complete the authentication process.

<img src="https://mintcdn.com/endorlabs-b4795f4f/dHzwUrp_QbpzV9uv/images/developers-api/cli/init-auth-mode.webp?fit=max&auto=format&n=dHzwUrp_QbpzV9uv&q=85&s=f63fde25d5e52e50995a78a0fd7eb185" alt="Init authentication through browser" width="755" height="722" data-path="images/developers-api/cli/init-auth-mode.webp" />

You can also specify your supported authentication provider manually:

<Tabs>
  <Tab title="Google">
    ```bash theme={null}
    endorctl init --auth-mode=google
    ```
  </Tab>

  <Tab title="GitHub">
    ```bash theme={null}
    endorctl init --auth-mode=github
    ```
  </Tab>

  <Tab title="GitLab">
    ```bash theme={null}
    endorctl init --auth-mode=gitlab
    ```
  </Tab>

  <Tab title="Email">
    ```bash theme={null}
    endorctl init --auth-email=`<insert_email_address>`
    ```
  </Tab>

  <Tab title="SSO">
    ```bash theme={null}
    endorctl init --auth-mode=sso --auth-tenant=`<insert-your-tenant>`
    ```
  </Tab>
</Tabs>

To log in with your supported authentication provider in environments without a browser you can use headless mode:

<Tabs>
  <Tab title="Google">
    ```bash theme={null}
    endorctl init --auth-mode=google --headless-mode
    ```
  </Tab>

  <Tab title="GitHub">
    ```bash theme={null}
    endorctl init --auth-mode=github --headless-mode
    ```
  </Tab>

  <Tab title="GitLab">
    ```bash theme={null}
    endorctl init --auth-mode=gitlab --headless-mode
    ```
  </Tab>

  <Tab title="Email">
    ```bash theme={null}
    endorctl init --auth-email=`<insert_email_address>` --headless-mode
    ```
  </Tab>

  <Tab title="SSO">
    ```bash theme={null}
    endorctl init --auth-mode=sso --auth-tenant=`<insert-your-tenant>` --headless-mode
    ```
  </Tab>
</Tabs>

### Login with an API Key

To log in with an API key you'll need to set the following environment variables:

* **ENDOR\_API\_CREDENTIALS\_KEY** - The API key used to authenticate against the Endor Labs API.
* **ENDOR\_API\_CREDENTIALS\_SECRET** - The API key secret used to authenticate against the Endor Labs API.
* **ENDOR\_NAMESPACE** - The Endor Labs namespace you would like to scan against. You can locate the namespace from the top left hand corner of the screen under the Endor Labs logo on the [Endor Labs application](https://app.endorlabs.com).

To get an API Key and secret for use with endorctl, see [Managing API Keys](/platform-administration/api-keys).

To set your environment variables run the following commands and replace each example with the appropriate value.

```bash theme={null}
export ENDOR_API_CREDENTIALS_KEY=<example-api-key>
export ENDOR_API_CREDENTIALS_SECRET=<example-api-key-secret>
export ENDOR_NAMESPACE=<example-tenant-namespace>
```

Once you've exported your environment variables you can test successful authentication by running the following command to list projects in your namespace.

```bash theme={null}
endorctl api list -r Project --page-size=1
```

<Note>
  If you do not have any projects in your namespace you will get an empty json output, which means you are successfully authenticated.
</Note>

### Print your access token

Once you have successfully initialized endorctl, you can print your access token with the following command.

```bash theme={null}
endorctl auth --print-access-token
```

The token has an expiration time of 4 hours.

## Persistently set environment variables for endorctl

To persistently set an environment variable, append the environment variable and the value to `~/.endorctl/config.yaml`. This configuration file is for CLI usage.

For example, if your GitHub Enterprise Server URL was [https://api.github.com](https://api.github.com) you can set the variable to persist in your configuration using the following command.

```bash theme={null}
echo "ENDOR_SCAN_SOURCE_GITHUB_API_URL: https://api.github.com" >> ~/.endorctl/config.yaml
```

See [endorctl commands for all supported commands and environment variables](/developers-api/cli/environment-variables).
