# Installing and configuring the CLI

# Getting Started with the Crusoe CLI

## Installing and Configuring the CLI

### Step 1: Install

You can install the Crusoe CLI via a number of common package managers, including `brew` and `apt`.

**Mac OS:**

On Mac, use [`homebrew`](https://brew.sh) to install the Crusoe CLI:

```sh
brew install crusoecloud/cli/crusoe
```

To upgrade to a newer version of the CLI, use `brew upgrade crusoe`.

**Linux:**

On Linux, use `apt` to install the Crusoe CLI:

```sh
echo "deb [trusted=yes] https://apt.fury.io/crusoe/ * *" > /etc/apt/sources.list.d/fury.list
sudo apt update
sudo apt install crusoe
```

To upgrade to a newer version of the CLI, use `sudo apt upgrade crusoe`.

Otherwise, to use `yum`, visit the [latest GitHub release](https://github.com/crusoecloud/cli/releases/latest) and download the `.rpm` asset suited for your machine, and run `sudo yum install <path_to_crusoe_rpm.rpm>`.

**Windows:**

On Windows, visit the [latest GitHub release](https://github.com/crusoecloud/cli/releases/latest) and download the `crusoe_Windows_$PLATFORM.tar.gz` asset suited for your machine (e.g. `crusoe_Windows_arm64.tar.gz`), untar it, and add the binary to your system PATH.

### Step 2: Get your API Keys from the Console

To authenticate with the Crusoe CLI, you will need an API access key ID and a secret key. You can generate these in the Crusoe Cloud console from the [Security page](https://console.crusoecloud.com/security/tokens).

:::warning
**Warning:** You will only be able to view the Secret key once! Ensure that you save it somewhere secure before you refresh or leave the page.
:::

### Step 3: Configure the CLI with Defaults for your Account

Run the following command to set up defaults for the CLI to use. It will ask for the API keys saved above, and a project, which can be found on your [Projects page](https://console.crusoecloud.com/projects). Under the hood, this will create and populate a `default` profile in `~/.crusoe/config`.

```sh
crusoe config init
```

To see current values for your default profile, use `crusoe config get <variable>`. To update them, use `crusoe config set <variable> <value>`. The variables are `default_project`, `access_key_id`, `secret_key`, and optionally, `ssh_public_key_file`.

### Step 4: Test the CLI

If you've properly installed and configured the CLI, you should be able to run the `crusoe whoami` command and see the logged-in user:

```sh
> crusoe whoami
<Full name> user@domain.com
```

You're ready to go! Now, try [creating a VM](/quickstart/creating-a-vm).

## Alternative Ways to Configure the CLI

### Using the Config File Directly and Switching Between Multiple Projects

You can edit your config directly to work with multiple profiles. To validate your changes, run:

```sh
$ cat ~/.crusoe/config

[default]
default_project="<project_name>"
access_key_id="<access_key_id>"
secret_key="<secret_key>"
ssh_public_key_file=</path/to/ssh/public/key/file>

[my-other-environment]
default_project="<project2_name>"
access_key_id="<access_key_id>"
secret_key="<secret_key>"
ssh_public_key_file=</path/to/ssh/public/key/file>
```

To switch between multiple profiles in your `~/.crusoe/config` file, use the environment variable `CRUSOE_PROFILE` (e.g., `export CRUSOE_PROFILE="my-other-environment"`).

### Use Environment Variables

To use the CLI without a config file, or to override its values, set analogous environment variables:

- `CRUSOE_DEFAULT_PROJECT`
- `CRUSOE_ACCESS_KEY_ID`
- `CRUSOE_SECRET_KEY`

## Conclusion

You can now explore all of the easy-to-use CLI commands for managing your AI infrastructure. Use `crusoe --help` to get started. Now, try [creating a VM](/quickstart/creating-a-vm) with the CLI.

If you're having issues, check that you've properly installed the CLI, have a config file locally at `~/.crusoe/config`, and see a default profile with your API keys. If this still isn't working, [contact support](/resources/support).