Skip to main content
Skip table of contents

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

image-20240418-212018.png

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 is installed.

  • Have an active Mend license.

  • Obtain your service user key (recommended) or your user key:

    • Service user key: Mend Platform Application → AdministrationUsers → locate service user → Copy Token

    • Your user key: Mend Platform Application → My ProfileUser Keys.

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

You can log in to the Mend CLI by defining 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 Manage service users in the Mend Platform documentation.

To define the variables in your environment, you can:

  • Set environment variables prior to 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 prior to 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.

image-20240906-150508.png

Reference

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 Mend environment
Environment Variable: MEND_URL

Select the Mend environment URL of your shared instance. The supported values are:

  • https://saas.mend.io

  • https://saas-eu.mend.io

  • https://app.mend.io

  • https://saas-il.mend.io

  • https://saas.whitesourcesoftware.com

  • https://saas-eu.whitesourcesoftware.com

  • https://app-eu.whitesourcesoftware.com

  • https://app.whitesourcesoftware.com

Command Line: Select Mend products

Select the Mend product(s) that you are authenticating for. The supported value is:

  • SCA (Dependencies) / CN (Image) - Authenticate for Mend CLI SCA and Mend CLI Container Image scans

  • SAST (Code) - Authenticate for Mend CLI SAST scans

Command Line: User Email
Environment Variable: MEND_EMAIL

Input your user email that has access to the Mend organization from the Mend Platform Application → My ProfileIdentity page.

Command Line: User Key
Environment Variable: MEND_USER_KEY

Input your service user key (recommended) or your personal user key that has access to the Mend organization:

  • Service user key: Mend Platform Application → AdministrationUsers → locate service user → Copy Token

  • Your user key: Mend Platform Application → My ProfileUser Keys.

Command Line: Select Mend organization
Environment Variable: MEND_ORGANIZATION

Command Line: Select the Mend organization that you want to authenticate to from the provided organization list.

Environment Variable: Provide your organization UUID. This can be found within the Mend Platform Application via settings(:mp_cogicon:) → Administration GeneralOrganization UUID:

Tip: You can also access your organization’s UUID via Mend’s API 3.0 login call (baseUrl/api/v3.0/login) and sending the username and userKey to receive your JWT token (learn more), then use the JWT to call baseUrl/api/v3.0/login/accessToken to retrieve the uuid (learn more).

Mend CLI - mend config parameters

Parameter

Description

Command Line:[Updates] Enable automatic updates? (Y/n, current: )

Default Value: Y (Yes): Automatic Updates enabled. Toggle automatic updates for the Mend CLI:

  • Y: Yes. Enable automatic updates for the Mend CLI.

  • n: No. Disable automatic updates for the Mend CLI.

  • current: Your current, active configuration.

Command Line:[Proxy] Change proxy settings? (y/N/reset, current: )

Whether to start the set up process for configuring a proxy:

  • y: Yes. Start the proxy setup process.

  • N: No. Do not start the proxy setup process. The mend config command will exit with a Configuration completed message.

  • reset: Remove your current proxy setup. This will set the proxy settings back to the default value, None.

  • current: Default Value: None (No proxy configured). Your current, active configuration.

Command Line:[Proxy] URL (current: )
Environment Variable (All scan types): HTTP_PROXY

Enter the URL of your proxy.

  • current: Default Value: None (No proxy URL configured). Your current, active configuration.

Command Line:[Proxy] Configure proxy authentication? (y/N)

Whether to start the set up process of configuration proxy credentials:

  • y: Yes. Start the proxy credential setup process.

  • N: No. Do not start the proxy credential setup process.

Command Line:[Proxy authentication] Username (current: )
Environment Variable (All scan types): HTTP_PROXY_USERNAME

Enter the username of your proxy authentication.

  • current: Default Value: None (No proxy username configured). Your current, active configuration.

Command Line:[Proxy authentication] Password (current: )
Environment Variable (All scan types): HTTP_PROXY_PASSWORD

Enter the password of your proxy authentication.

  • current: Default Value: None (No proxy password configured). Your current, active configuration.

 

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.