Authenticate your login for the Mend CLI
Overview
You must log in to the Mend CLI once for each environment where it runs, which authenticates you to work in a single organization.
Mend CLI login example
Getting it done
Prerequisites before you log into the Mend CLI
The following operating systems are supported by the Mend CLI:
Linux (Intel and ARM processors): Ubuntu, Debian, and other flavors which have glibc (GNU C library)
Windows: Windows 10/11 or Windows Server 2016 and higher
MacOS - Docker for Mac installed.
Have an active Mend license.
Obtain your service user key (recommended) or your personal user key:
For SCA/Container Image:
Service user key: Mend Application → Admin → Users → locate service user → copy token
Your user key: Mend Application → My Profile → User Keys
For SAST:
Service user key: Mend SAST Application → Users → Service Users → locate service user → Show token
Your user key: Mend SAST Application → Settings → API Token
Log in to the Mend CLI via the interactive terminal
You can log in to the Mend CLI interactively by entering mend auth login
in your terminal:
Log in to the Mend CLI via environment variables
Log in to the Mend CLI by defining credentials via environment variables.
Tip: As a common best practice, we strongly recommend creating and using a service user when configuring the Mend CLI authentication through environment variables in your CI/CD pipelines. Read more on service users in our articles below:
For Mend CLI SCA/Container Image scans: Managing Service Users
For Mend CLI SAST scans: Users Tab
To define the variables in your environment, you can:
Set environment variables before the Mend CLI run to persist between sessions:
In MacOS and Linux, use a shell startup script
In Windows, use the
setx
command.setx VARIABLE "MYVALUE"
Set environment variables before the Mend CLI run, for the current session only:
In MacOS and Linux, use the
export
command.export VARIABLE=value
In Windows, use the
set
command.set VARIABLE=value
Note: If you receive this error: Executing <mend dependencies> and the corresponding help command requires to authenticate first, either through environment variables or by executing mend auth login
.
Remove any MEND_SAST_*
variables from your environment and rerun the SCA scan.
For more information on MEND_SAST_*
variables, refer to our CLI Parameters documentation.
Set up a proxy and automatic updates for the Mend CLI
You can set up a proxy as well as toggle automatic updates for the Mend CLI for all scan types using the mend config
command. Read through our mend config parameters section within this documentation to learn more.
Note:
When automatic updates are disabled, the Mend CLI will still check for updates and notify you that a new version is available to download.
When running a Mend CLI scan with proxy enabled, the terminal output and logs will notify you that a proxy is being used after executing a command:
Running with proxy - https:/myproxy.prx
.
Verify the connection from the Mend CLI to the Mend Server
You can verify the connection from the Mend CLI on your environment to the Mend Server using the mend connectivity
command. The command checks if all external URL resources needed during the scan are accessible with the current network/proxy settings and reports an error for each URL where the access attempt fails.
To check the connectivity, you should:
Use the
mend connectivity --mend-url="MEND_URL"
command and insert the “Mend_URL” value for the connection test.MEND_URL represents the Mend environment URL. The supported values are available in Mend CLI - mend auth login parameters.
Reference
Mend SAST Login
Mend SCA/Container Image Login
Mend CLI - mend auth login parameters
Note: For inline help, use mend auth login -h
or mend auth login --help
.
Parameter | Description |
---|---|
Command Line: | Select the Mend environment URL of your shared instance. The supported values are:
Note: The |
Command Line: | Select the Mend product(s) that you are authenticating for. The supported values are:
|
Command Line: | Input your user email that has access to the Mend organization.
|
Command Line (SCA/Container Image): | Input your service user key (recommended) or your personal user key that has access to the Mend organization.
|
Command Line: | Command Line: (SAST Only) Select the Mend organization that you want to authenticate to from the provided organization list. Environment Variable: (SAST Only) Provide your SAST organization UUID. |
Mend CLI - mend config parameters
Parameter | Description |
---|---|
Command Line: | Default Value:
|
Command Line: | Whether to start the set up process for configuring a proxy:
|
Command Line: | Enter the URL of your proxy.
|
Command Line: | Whether to start the set up process of configuration proxy credentials:
|
Command Line: | Enter the username of your proxy authentication.
|
Command Line: | Enter the password of your proxy authentication.
|