This quickstart takes approximately 5 minutes to complete.
Prerequisites
Before you begin, make sure you have:- A Harness account (sign up at app.harness.io)
- A Harness API token (you’ll generate this during authentication)
- Terminal access on Linux, macOS, or Windows
Step 1: Install the CLI
Install the Harness CLI using our quick install script:Step 2: Authenticate with Harness
The CLI needs to authenticate with your Harness account. You can do this interactively or with flags.Interactive authentication (recommended)
Run the login command and follow the prompts:API URL
Press Enter to use the default (
https://app.harness.io) or enter your custom Harness instance URL.API Token
Enter your Harness API token. To generate one:
- Go to app.harness.io
- Click your profile icon → My API Keys
- Click + API Key → + Token
- Give it a name and click Generate Token
- Copy the token (it won’t be shown again)
The token format is
pat.AccountID.Random.Random. The CLI automatically extracts your account ID from the token.Your credentials are saved to
~/.harness/auth.json with permissions set to 0600 (owner read/write only) for security.Non-interactive authentication
For automation and CI/CD pipelines, you can provide credentials via flags:Verify authentication
Check your authentication status:Step 3: Run your first commands
Now that you’re authenticated, let’s explore what you can do with the CLI.List artifact registries
See all registries in your account:Get registry details
View detailed information about a specific registry:List artifacts
See all artifacts across registries:Push an artifact
Upload a generic artifact to a registry:The
--pkg-url flag is required for push operations. It points to your Harness package API endpoint.Using different output formats
All list and get commands support table (default) or JSON output:Common workflows
Now that you know the basics, here are some common workflows:Managing registries
Managing registries
Working with artifacts
Working with artifacts
Pushing artifacts
Pushing artifacts
The CLI supports multiple package types. Here are some examples:
Pulling artifacts
Pulling artifacts
Using global flags
All commands support global flags that override your saved configuration:Configuration precedence (highest to lowest):
- Command-line flags
- Environment variables
- Configuration file (
~/.harness/auth.json)
Troubleshooting
Not logged in error
Not logged in error
If you see “Not logged in. Please run ‘hc auth login’ first”:
- Run
hc auth loginto authenticate - Or provide credentials via environment variables or flags
Authentication failed
Authentication failed
If credential validation fails:
- Verify your API token is still valid in the Harness UI
- Check that you’re using the correct API URL
- Ensure your token has the necessary permissions
Command not found
Command not found
If you get “command not found: hc”:
- Verify installation:
which hc - Check that
/usr/local/binis in your PATH - Try reinstalling or installing to a custom directory
Enable debug logging
Enable debug logging
For detailed debugging information, use the This shows HTTP requests, responses, and internal operations.
--verbose flag:Next steps
You’re now ready to explore the full power of the Harness CLI:Authentication concepts
Learn about advanced authentication methods and security best practices.
Configuration guide
Configure the CLI for your workflow with profiles and environment variables.
Registry migration
Migrate artifacts from external registries to Harness.
Command reference
Explore the complete command reference with all options and examples.
Need help? Check our troubleshooting guide or FAQ.