V1
Installation
Install the Harness CLI on Unix-based systems (macOS, Linux) using the following command:
curl https://raw.githubusercontent.com/harness/harness-cli/v2/install | shThis script will download and install the latest version of the CLI to your system.
Version Check
After installing the CLI, verify the installation by checking the version:
hc versionExample output:
hc version dev
Built with go1.24.9Upgrade to Latest Version
To ensure you have the latest features and bug fixes, upgrade the Harness CLI to the latest version:
hc upgradeAuthentication Setup
To authenticate the CLI with your Harness account, use the login command:

You will be prompted to provide the following details:
URL: Your Harness platform URL
API Token Key: Your personal access token or API key (learn how to create API keys)
Account ID: Your Harness account identifier
Organization ID: Your organization identifier (optional)
Project ID: Your project identifier (optional)
Once authenticated, the CLI will store your credentials securely for subsequent commands.
Basic Verification
After authentication, verify your connection by performing a basic operation, for example, listing your registries:
This command should display your available registries, confirming a successful connection. 
Using the CLI Binary
If you've downloaded the CLI binary directly, you may need to run it using ./hc from the directory where it's located:
Adding to PATH
To use hc from anywhere without the ./ prefix, add the CLI binary to your system PATH:
macOS/Linux:
Move the binary to a directory in your PATH (e.g.,
/usr/local/bin):Make sure it's executable:
Verify you can now use
hcfrom anywhere:
Alternative: Add to PATH without moving
If you prefer to keep the binary in its current location, add that directory to your PATH:
To make this permanent, add the above line to your shell configuration file (~/.bashrc, ~/.zshrc, or ~/.bash_profile).
Last updated
Was this helpful?