Skip to main content

Who is this article for?

Code42 for Enterprise
CrashPlan for Small Business

Code42 for Enterprise, yes.

CrashPlan for Small Business, no.

This article applies to Code42 cloud environments.

HOME
GETTING STARTED
RELEASE NOTES
FAQS
SYSTEM STATUS
Code42 Support

Set up the Code42 command-line interface

Who is this article for?

Code42 for Enterprise
CrashPlan for Small Business

Code42 for Enterprise, yes.

CrashPlan for Small Business, no.

This article applies to Code42 cloud environments.

Overview

The Code42 command-line interface (CLI) tool offers a way to interact with your Code42 environment without using the Code42 console or making API calls directly. For example, you can use it to extract Code42 data for use in a security information and event management (SIEM) tool or manage users on the High Risk Employees list or Departing Employees list. This article provides instructions for installing, uninstalling, and upgrading the Code42 CLI. 

Requirements

To use the Code42 CLI, you must have:

This functionality is available only when supported by your product plan. Contact your Customer Success Manager (CSM) for assistance with licensing, or to upgrade to the Incydr Advanced product plan for a free trial​​​. If you don't know who your CSM is, email csmsupport@code42.com

 

Create a user in Code42

Prepare a user account in your Code42 environment to use with the Code42 CLI. This user account is used to authenticate and access data in your Code42 environment.

Permissions

The Code42 CLI returns data based on the roles assigned to this user. To ensure that the user's rights are not too permissive, create a user with the lowest level of privilege necessary. The Customer Cloud Admin or Security Center User role has the permissions necessary to execute the commands in this tool. We recommend you test to confirm that the user can access the right data.   

Licensing

As a best practice, we recommend creating a user in your Code42 environment that is exclusively used to run Code42 CLI commands. Users without a Code42 app archive will not consume a license. 

Authentication

Your Code42 credentials must rely on local authentication. SSO or authentication through any third-party provider will not work.

Credential storage

The way your Code42 CLI credentials are stored depends on the operating system on which you're running the Code42 CLI. Click the expander icons below for your system's details.  

Windows and Mac

Red Hat Enterprise Linux

Ubuntu

Install 

The Code42 CLI is available on the Python Package Index (PyPI). To install it:

  1. Open your terminal program.
  2. Run the following command at the system level:   
python3 -m pip install code42cli

Verify installation

To verify that the Code42 CLI installed successfully, run the following command: 

pip show code42cli

Configure profile

Use the code42 profile set of commands to establish the Code42 environment you're working within and your user information. 

code42 profile

Command Description
create

Create a named profile with the URL and user credentials you'll use to connect to your Code42 environment. Required arguments: 

  • --name A name you assign the profile, for your reference
  • --server Authority URL: Enter the URL you use to sign in to the Code42 console.
  • --username Enter your Code42 username. See Create a user in Code42 above for detailed user requirements.  

 

Example: code42 profile create --name profile1 --server https://console.us.code42.com/ --username marlon.nunez@example.com

 

The Code42 CLI offers the prompt "Would you like to set a password? (y/n)"  If you select no, you'll be prompted to enter the password along with each command you enter. If you select yes, the password is retained until you use the reset-pw command.

update

Update an existing profile, for example, to correct an error in the username or authority server URL. Optional arguments: 

  • --name
  • --server
  • --username
show

Displays the default profile.

 

Add --name with the profile name to display the details of that profile, for example: 

code42 profile show --name profile1

list

Lists all the profiles currently set up.

 

Having multiple profiles can help facilitate running incremental queries. The previous date and time an incremental query was run is specific to the profile used

delete

Deletes the profile and its stored password (if any). You must include the name of the profile to delete. Example: 

code42 profile delete profile1

delete-all Deletes all profiles and stored passwords (if any).  
use

Sets the default profile. The default profile is used unless --profile is included in the query command

reset-pw Resets the password set with the current profile.

Use cases

Using the Code42 CLI, you can manage users on the High Risk Employees list or Departing Employees list, and query security event data for use in a SIEM tool. For more information, see the articles linked below: 

Upgrade

To see the latest version of the Code42 CLI, visit the Python Package Index (PyPI). You can check what version you currently have installed by running the command described under Verify installation above.

To upgrade the Code42 CLI, run the following command in a terminal window:  

python3 -m pip install --upgrade code42cli

Uninstall 

To uninstall the Code42 CLI, run the following command in a terminal window:

python3 -m pip uninstall code42cli  

External resources

Download Python

  • Was this article helpful?