Skip to main content

Sonatype CLI

The Sonatype CLI provides a common command-line interface for Sonatype products. Run a product command in the form sonatype <product> ....

Firewall Enterprise (FWE) is the first product available through the CLI. You run it with the fwe command, for example sonatype fwe run npm install. For setup and first-run instructions, see Getting Started with Firewall Enterprise (FWE).

Download

Latest version:

Download Sonatype CLI for Linux (x86-64 or AArch64), macOS (Intel or Apple silicon), or Windows (x86-64).

Available Packages

Platform

Download

Linux (x86-64)

Linux (AArch64)

macOS (x86-64)

macOS (AArch64)

Windows (x86-64)

Command Structure

Use one of the following forms to run a general CLI command or a product command:

sonatype [global options] <command> [options]
sonatype [global options] <product> [command] [options]

For example, run a package manager through Firewall Enterprise (FWE) or run a general CLI command:

sonatype fwe run npm install
sonatype doctor

CLI parameters

Commands

Commands that do not require a product include:

Command

Purpose

setup

Guided first-run setup.

auth

Log in, check status, or log out.

config

Manage configuration with get, set, unset, list, path, and repository.

ca

Manage the certificate used to inspect traffic with install, status, and uninstall. Required once on macOS to run dotnet; see Firewall Enterprise (FWE).

doctor

Diagnose the installation.

diagnostic-bundle

Create a diagnostic archive. Credentials are removed, but the archive still includes the IQ Server URL, username, and local file paths.

completion

Generate a shell completion script for bash or zsh.

version

Print the version.

Command options

Command

Option or argument

Description

setup

--offline

Skip checks that need network access.

auth login

--url URL

Required. Specify the IQ Server URL. It must start with https://; plain http:// is accepted only for a server on your own machine. This value is not read from fwe.url.

auth login

--token-stdin

Read the password or token from standard input.

auth login

--no-verify

Store the credential without checking it against IQ Server.

auth login

--credential-store file

Store the credential in ~/.sonatype/cli/credentials instead of the operating system store. This file is plain text; fwe run does not read credentials from it.

auth status

--offline

Report local state only; do not contact IQ Server.

auth status

--credential-store file

Check the credential in the file store.

auth logout

--credential-store file

Remove the credential from the file store.

config get

KEY

Print the effective value of a setting.

config set

KEY VALUE

Save a setting in the user configuration file.

config set

--local

Save the setting in ./.sonatype/cli/config.yaml in the current folder.

config unset

KEY, --local

Remove a setting from the user or local configuration file.

config list

List settings, their values, and where they came from.

config path

Show the configuration files in use, in priority order.

config repository

--format FORMAT, --id ID

Set a repository ID for one format. Provide both options, or neither to use the guided form. Format values are npm, maven2 (Maven and Gradle), pypi, and nuget.

config repository

--local

Save the repository setting in the project configuration file.

ca install, ca uninstall

--sudo

On Linux, run the trust-store commands with sudo.

ca status

--check

Exit with code 4 unless the CA is on disk and trusted by the operating system.

doctor

--offline

Skip checks that need network access.

diagnostic-bundle

--output-file PATH

Choose where to write the archive. By default, it is saved in ~/.sonatype/cli/diagnostics/ with a UTC timestamp in the filename.

diagnostic-bundle

--offline

Skip checks that need network access.

completion

bash or zsh

Print the completion script for the specified shell. Use lower case.

Global options

Global options work before or after the command name. For fwe run, put them before the package manager name; arguments after the package manager name are passed to it unchanged.

Option

Description

--output <text|json>

Set the output format to text or json (lower case).

--verbose / --quiet

--verbose shows debug messages on standard error. --quiet shows warnings and errors only. These options cannot be combined.

--no-colour, --no-color

Disable colours.

--profile NAME

Use a named configuration profile.

--config FILE

Use a specific configuration file.

--log-file <path>

Write detailed (debug-level) records as JSON lines to the specified path, regardless of --verbose or --quiet. The CLI creates the folder if needed, and the file is readable only by you.

--no-tui

Accepted for compatibility. The CLI has no interactive screen. This option also stops setup from asking questions.

-h, --help

Show help for the command.

-V, --version

Print the version. This option works only directly after sonatype; use sonatype version elsewhere.

Every CLI option has a corresponding environment variable named SONATYPE_CLI_<OPTION>. Boolean environment variables accept only true or false; 1 is rejected with exit code 2. The environment variables for --no-colour and --no-color use the British spelling: SONATYPE_CLI_NO_COLOUR. From lowest to highest priority: built-in default, configuration file, environment variable, command-line option. This priority applies to CLI options. Settings that start with fwe. come only from configuration files and have no corresponding option or environment variable.

Environment variables

Variable

Purpose

SONATYPE_CLI_FWE_TOKEN

Provide the IQ password or user token for every profile. This takes priority over a stored credential and is the supported way to provide the credential on Linux.

SONATYPE_CLI_FWE_TOKEN_<PROFILE>

Provide a credential for one profile. Use uppercase letters in the profile name and replace hyphens with underscores. This variable takes priority over SONATYPE_CLI_FWE_TOKEN.

NO_COLOR

Any value disables coloured output.

CI

When set to exactly true, ca install exits with code 4 instead of prompting, and the CLI does not draw the interactive table.

There are no environment variables for settings that start with fwe.. Set them in a configuration file; see Firewall Enterprise (FWE).

Firewall Enterprise (FWE) run options

For fwe run, put every CLI option before the package manager name. Arguments after the package manager name are passed to that tool unchanged. The fwe run command does not provide a help screen; sonatype fwe run --help returns a usage error.

Option

Description

--output json

Generate a JSON report. Specify this with --output-file to write the report to a file.

--output-file <path>

Write the JSON report to the specified path. This option does not produce a report unless you also specify --output json.

Include the explicit run command when generating a report. For example:

sonatype fwe run --output json --output-file ./report.json npm install

For Firewall Enterprise configuration and mode settings, see Firewall Enterprise (FWE).

There is no help command. Use --help to display help for the CLI, a product, or a command:

sonatype --help
sonatype <product> --help
sonatype config set --help

Running sonatype with no arguments also displays help. An unknown command exits with code 2 and lists the valid commands.

Exit Codes

Code

Meaning

0

Success.

1

The command failed. For fwe run, this is usually the package manager’s failure code, including when a package is blocked. For example, npm returns 1.

2

Usage error, such as an unknown command or option.

3

Reserved. Not currently returned.

4

Configuration, credential, or authentication problem. Run sonatype doctor.

5

fwe run in block mode only: downloads went through the CLI, but none could be identified, so no policy was enforced.

127

fwe run could not find or start the package manager tool.

130, 143

fwe run was interrupted with Ctrl-C (130) or SIGTERM (143). Tested on macOS and Linux.

fwe run does not use a dedicated exit code for a blocked component. It returns the package manager’s exit code, which varies by tool; for example, uv returns 2 when a package is blocked. These exit codes do not have the same meanings as Sonatype IQ CLI exit codes.

Products