Install and configure Workbench CLI credentials

Updated at:

After you install Workbench CLI on your local Linux, macOS, or Windows machine, attach a least-privilege policy to a RAM user, then generate and configure an AccessKey for ready-to-use credential access. In production environments, you can switch to RamRoleArn, CredentialsCmd, or CredentialsURI to enable automatic credential refresh and least privilege.

Limits

  • Target instance operating system: Workbench CLI can connect only to Linux instances over Secure Shell Protocol (SSH) and cannot connect to Windows instances.

  • Local machine operating system: Workbench CLI itself runs on Linux, macOS (amd64 / arm64), and Windows (amd64).

  • Network connectivity: The local machine must be able to access *.aliyuncs.com and the Workbench backend WebSocket endpoint.

Important

Windows instances are not currently supported by Workbench CLI. To connect to a Windows instance, see Connect using Workbench.

Step 1: Install Workbench CLI

Select the installation command according to the local machine's operating system. The installation script automatically detects the architecture (amd64 / arm64), downloads the binary from the OSS CDN, verifies the SHA256 checksum, and installs it to the default system path.

Linux or macOS

Run the following command to install the latest version of Workbench CLI.

curl -fsSL https://workbench-cli.oss-cn-hangzhou.aliyuncs.com/install.sh | bash
Note

The installation script will automatically download the checksum file and verify the installation package. If the verification fails, the installation will be aborted; if it passes, the script will output checksum OK.

After installation, the binary is located at /usr/local/bin/workbench. On macOS, the binary is automatically re-signed and its quarantine attribute is removed. If the target directory requires administrator privileges, the script automatically uses sudo.

Windows

Run the following command in PowerShell to install the latest version of Workbench CLI.

irm https://workbench-cli.oss-cn-hangzhou.aliyuncs.com/install.ps1 | iex
Note

The installation script will automatically download the checksum file and verify the installation package. If the verification fails, the installation will be aborted; if it passes, the script will output checksum OK.

After installation, the binary is located at C:\Program Files\workbench\, and the installation script automatically configures the PATH environment variable. When you install in a desktop or Remote Desktop Protocol (RDP) session, the PATH takes effect only after you sign out and sign back in.

If the installation package is obtained through other channels (such as an offline package or an internal mirror), verify the installation package before installation to ensure its integrity and security.

Verify the installation

After installation, run the following command to verify:

workbench version

Normally, it outputs the current version number, commit ID, and build date. If you see command not found, it is usually because the PATH has not taken effect. You can take the following actions:

  • Linux / macOS: Reopen the terminal window, or run source ~/.bashrc (or ~/.zshrc) and try again.

  • Windows: Close and reopen the PowerShell window so that the new PATH takes effect.

Step 2: Prepare an AccessKey with least-privilege permissions for Workbench CLI

Workbench CLI calls Alibaba Cloud APIs by using an AccessKey. The goal of this step is to obtain an AccessKey that has only the minimum permissions required by Workbench CLI, so that you can configure it in the CLI on your local machine in the next step. The recommended procedure is: Create a RAM user → Grant the minimum permissions → Create an AccessKey for the RAM user.

Important

Do not use the AK/SK of your Alibaba Cloud account to configure the CLI. The AccessKey of an Alibaba Cloud account has operation permissions on all cloud resources under that account. If it is leaked, all your assets are exposed. Always use the AccessKey of a RAM user that has only the minimum required permissions.

Note

If you already have a RAM user that meets the minimum permissions required by Workbench CLI, skip steps 1 to 3 and start directly from Step 4: Create an AccessKey for the RAM user.

  1. Create a RAM user. Log on to the RAM console, and go to the Identities > Users page. Click Create User. On the creation page, enter User Login Name and Display Name, and then click OK.

    Do not create an AccessKey at this point. The AccessKey is created in step 4, after the authorization is complete.

  2. Create a custom policy. In the RAM console, go to the Permissions > Policies page, and click Create Policy, switch to Script Editor mode, paste the following JSON, and then click OK.

    {
      "Version": "1",
      "Statement": [
        {
          "Effect": "Allow",
          "Action": [
            "ecs-workbench:*"
          ],
          "Resource": "*"
        },
        {
          "Effect": "Allow",
          "Action": [
            "ecs:DescribeInstances",
            "ecs:DescribeCloudAssistantStatus",
            "ecs:StartTerminalSession"
          ],
          "Resource": "*"
        },
        {
          "Effect": "Allow",
          "Action": "ram:CreateServiceLinkedRole",
          "Resource": "*",
          "Condition": {
            "StringEquals": {
              "ram:ServiceName": "workbench.ecs.aliyuncs.com"
            }
          }
        }
      ]
    }

    The following table describes the purpose of each Action in the policy:

    Action

    Purpose

    ecs:DescribeInstances

    workbench list ecs Queries the instance list.

    ecs:DescribeCloudAssistantStatus

    Checks the Cloud Assistant Agent status of the target instance.

    ecs:StartTerminalSession

    Establishes a terminal session with the ECS instance.

    ecs-workbench:LoginECSInstance

    Password-free logon through the Workbench channel (used by connect, exec, upload, and download).

    ecs-workbench:ChatMessages

    Permissions required by the in-session AI Agent assistant (/agent mode).

    ecs-workbench:EndSessions

    Closes the Workbench session (called by session close and by automatic session cleanup).

    ram:CreateServiceLinkedRole

    Creates the Workbench service-linked role on first use, and uses Condition to restrict creation to the service-linked role of the workbench.ecs.aliyuncs.com service.

    The preceding policy grants access to all instances by default. To narrow the scope to specific instances, use instance ARNs only for operations that support instance-level authorization, and split them into separate Statement as needed to modify Resource:

    "Resource": "acs:ecs:<region>:<account-id>:instance/<instance-id>"
    Note

    ecs-workbench:ChatMessages and ram:CreateServiceLinkedRole do not support narrowing by instance ARN and must remain "Resource": "*".

  3. Grant the policy to the RAM user. Go to the details page of the RAM user that you created in step 1 and click the Permissions tab. Click Grant Permission, select the custom policy that you created in the previous step, and complete the authorization. For instructions, see Manage the permissions of a RAM user.

  4. Create an AccessKey for the RAM user. On the details page of the RAM user, go to the Credentials > AccessKey tab, and click Create AccessKey. On the page that appears, select Use the AccessKey in the CLI, select I confirm that I must create an AccessKey, and then click Continue. For instructions, see Create an AccessKey pair.

    Important

    The AccessKey secret is displayed only once, when it is created, and cannot be viewed again after you close the page. Save the AccessKey ID and the AccessKey secret in a password manager or keystore immediately. If you lose them, you can only create a new AccessKey pair.

    An AccessKey is a long-term credential; once it is leaked, it can be abused for a long time.In production environments, switch to an automatically refreshing credential mode such as RamRoleArn as soon as you complete the configuration in Step 3. For details, see the More configuration methods section.

Step 3: Configure the AccessKey pair in the local CLI

Run the following command and enter the AccessKey ID and AccessKey secret obtained in Step 2 as prompted.

workbench config

After the configuration is complete, the credentials are saved in ~/.workbench/config.json, and the file permissions are automatically set to 0600 (readable and writable only by the current user). Example of the file content:

{
  "current": "default",
  "profiles": {
    "default": {
      "mode": "AK",
      "access_key_id": "LTAI...",
      "access_key_secret": "..."
    }
  }
}

Run the following command to verify that the connection works (replace cn-hangzhou with your actual region):

workbench list ecs -r cn-hangzhou

Under normal conditions, the list of instances in the region is returned. If an error such as InvalidAccessKeyId or NoPermission is returned, see the FAQ section.

(Optional) Set the interface language

Workbench CLI supports Chinese (zh) and English (en) as interface languages. By default, the interface language is Chinese. Run the following command to switch:

workbench config set language en   # Switch to English
workbench config set language zh   # Switch back to Chinese

You can also set the language in the workbench config interactive configuration flow, or directly edit ~/.workbench/config.json and, in the corresponding profile, add the language field:

{
  "current": "default",
  "profiles": {
    "default": {
      "mode": "AK",
      "language": "en"
    }
  }
}

After you make the change, it takes effect when you reconnect. You do not need to restart the daemon.

(Optional) Manage multiple profiles

If you need to switch between multiple Alibaba Cloud accounts or multiple sets of credentials, use the profile feature to avoid reconfiguring the credentials each time. All profiles are stored in the same ~/.workbench/config.json file, and the current field marks the active profile.

workbench config --profile prod          # Create or edit the prod Profile
workbench config list                    # List all profiles (* marks the active one)
workbench config get --profile prod      # Show the details of the specified profile
workbench config switch --profile prod   # Switch the active Profile
workbench config delete --profile old    # Delete a profile (the active profile cannot be deleted)
workbench exec -i i-xxx -c "hostname" --profile prod   # For this command only, use the specified Profile

config.json example with multiple profiles:

{
  "current": "default",
  "profiles": {
    "default": {
      "mode": "AK",
      "access_key_id": "LTAI...",
      "access_key_secret": "..."
    },
    "prod": {
      "mode": "RamRoleArn",
      "access_key_id": "LTAI...",
      "access_key_secret": "...",
      "ram_role_arn": "acs:ram::123456:role/prod",
      "role_session_name": "workbench"
    }
  }
}
Note

If the configuration file is still in the old flat format (without the profiles field), the CLI automatically migrates it to the new format on the first run and stores the existing credentials in a profile named default. No manual action is required.

More configuration methods

A static AccessKey is a long-term credential; once it is leaked, it can be abused for a long time. In production environments or when stricter security requirements apply, switch to one of the other six modes:

Mode

Applicable scenario

Configuration command

AK (Steps 2 to 3 in this topic)

A static AccessKey. Quick to get started in development environments.

workbench config --mode AK

StsToken

Temporary security credentials (an AccessKey pair and a Security Token Service (STS) token). Suitable when you already have STS temporary credentials.

workbench config --mode StsToken

RamRoleArn

Recommended for production environments: a low-privilege AK assumes a high-privilege RAM role, and the STS temporary credentials are refreshed automatically.

workbench config --mode RamRoleArn

CredentialsCmd

Obtains credentials dynamically from an external program, integrating with the credential distribution or secret management system that your enterprise already uses.

workbench config --mode CredentialsCmd

CredentialsURI

Obtains credentials dynamically from an HTTP service, such as a metadata service or a sidecar.

workbench config --mode CredentialsURI

EcsRamRole

The CLI runs on an ECS instance that is bound to a RAM role and obtains credentials automatically from the instance metadata service (IMDS).

workbench config --mode EcsRamRole

AliyunCLI

Reuses the credentials already configured in the Alibaba Cloud CLI on your local machine (~/.aliyun/config.json), without storing a fixed AK/SK on disk.

workbench config --mode AliyunCLI

Use STS temporary credentials (StsToken)

This mode authenticates directly with the temporary security credentials (AccessKey ID + AccessKey secret + STS token) obtained from STS. Use it when you already hold temporary credentials. Temporary credentials have an expiration time, and you must configure them again after they expire. To refresh the credentials automatically, use Use a RAM role (RamRoleArn).

Configuration method

workbench config --mode StsToken

Enter the following in sequence as prompted:

  • Access Key ID: the temporary AccessKey ID.

  • AccessKey Secret: the temporary AccessKey secret.

  • STS Token: the temporary access credential.

Configuration result preview

After completing the configuration, you can verify the credential configuration result by checking ~/.workbench/config.json. A complete configuration example is as follows:

{
  "current": "default",
  "profiles": {
    "default": {
      "mode": "StsToken",
      "access_key_id": "STS.LTAI...",
      "access_key_secret": "...",
      "sts_token": "..."
    }
  }
}

Use a RAM role (RamRoleArn)

This mode is suitable for scenarios in which a low-privilege AccessKey is used to assume a high-privilege RAM role. The CLI automatically calls STS AssumeRole to obtain temporary credentials and refreshes them before they expire. For more information about RAM role assumption, see Assume a RAM role.

Configuration method

workbench config --mode RamRoleArn

Enter the following information in sequence as prompted:

  • Access Key ID: the AccessKey ID that has the AliyunSTSAssumeRoleAccess permission.

  • Access Key Secret: the secret key that corresponds to the AccessKey ID.

  • RAM Role ARN: the ARN of the RAM role to assume (format: acs:ram::<account-id>:role/<role-name>)

  • Role Session Name: the session identifier, which is used for audit logs (default: workbench-session).

Configuration result preview

After completing the configuration, you can verify the credential configuration result by checking ~/.workbench/config.json.

You can add advanced fields (such as expired_seconds, sts_region, and external_id, which is used for cross-account confused deputy prevention) by manually editing config.json. For more information about the STS mechanism, see What is STS?.

TA complete configuration example is as follows:

{
  "current": "default",
  "profiles": {
    "default": {
      "mode": "RamRoleArn",
      "access_key_id": "LTAI...",
      "access_key_secret": "...",
      "ram_role_arn": "acs:ram::123456789:role/WorkbenchRole",
      "role_session_name": "workbench-session"
    }
  }
}

Use an external command credential (CredentialsCmd)

This mode is suitable for scenarios in which credentials are dynamically obtained through an external credential tool, such as aliyun-zerotrust-credential-provider, or a custom script. Each time the CLI needs credentials, it runs the configured command and parses the JSON output of the command as the credentials.

Configuration method

workbench config --mode CredentialsCmd

Enter the following information as prompted:

  • Process Command — the full path and parameters of the external credential command. The external credential command must meet the following requirements:

    • The exit code must be 0. A non-zero exit code is treated as a failure.

    • The standard output must be in the JSON format. The following two formats are supported:

      AK format (static credentials):

      {
        "mode": "AK",
        "access_key_id": "<AccessKeyID>",
        "access_key_secret": "<AccessKeySecret>"
      }

      StsToken format (temporary credentials):

      {
        "mode": "StsToken",
        "access_key_id": "<AccessKeyID>",
        "access_key_secret": "<AccessKeySecret>",
        "sts_token": "<SecurityToken>"
      }

Example 1: Use aliyun-zerotrust-credential-provider

aliyun-zerotrust-credential-provider is the Alibaba Cloud zero-trust credential command-line interface.

workbench config --mode CredentialsCmd
# Process Command input:
# /usr/local/bin/aliyun-zerotrust-credential-provider --app-name=myapp --role=acs:ram::123456789:role/WorkbenchRole

After completing the configuration, you can verify the credential configuration result by checking ~/.workbench/config.json. A complete configuration example is as follows:

{
  "current": "default",
  "profiles": {
    "default": {
      "mode": "CredentialsCmd",
      "process_command": "/usr/local/bin/aliyun-zerotrust-credential-provider --app-name=myapp --role=acs:ram::123456789:role/WorkbenchRole"
    }
  }
}

Example 2: Use a custom script

You can write a script as the credential source, as long as the script meets the output format:

#!/bin/bash
# ~/.workbench/get-creds.sh
# Obtain credentials from Vault or another key management system
vault read -format=json secret/aliyun | jq '{
  mode: "StsToken",
  access_key_id: .data.access_key_id,
  access_key_secret: .data.access_key_secret,
  sts_token: .data.security_token
}'

Use a credential URI (CredentialsURI)

This mode is suitable for scenarios such as a self-managed credential distribution service, the ECS instance metadata service, and a sidecar credential endpoint. The CLI sends an HTTP GET request to the configured URL to dynamically obtain temporary credentials, and automatically refreshes the credentials before they expire.

Configuration method

workbench config --mode CredentialsURI

Enter the following as prompted:

  • Credentials URI: The HTTP/HTTPS address of the credentials service. The credentials service response must meet the following requirements:

    • The response status code must be 200

    • The response body uses the following format:

      {
        "Code": "Success",
        "AccessKeyId": "<AccessKeyID>",
        "AccessKeySecret": "<AccessKeySecret>",
        "SecurityToken": "<SecurityToken>",
        "Expiration": "2026-01-01T12:00:00Z" 
      }
      Important

      Code field must be exactly Success (case-sensitive).Expiration is in ISO 8601 format, and the SDK automatically re-fetches the credentials before they expire.

Configuration result preview

After completing the configuration, you can verify the credential configuration result by checking ~/.workbench/config.json. A complete configuration example is as follows:

{
  "current": "default",
  "profiles": {
    "default": {
      "mode": "CredentialsURI",
      "credentials_uri": "http://localhost:8080/credentials"
    }
  }
}

Use an ECS instance RAM role (EcsRamRole)

Applies to scenarios where the CLI runs on an Alibaba Cloud ECS instance and the instance has a RAM role attached. The CLI automatically obtains temporary STS credentials directly from the instance metadata service (IMDS http://100.100.100.200) and requires no AccessKey. IMDS automatically refreshes the credentials before they expire.

Important

Available only on Alibaba Cloud ECS/ECI instances. Non-ECS environments (local machines, other clouds) cannot access IMDS, so this mode fails to obtain credentials. In that case, use a mode such as AK, RamRoleArn, or CredentialsURI.

Configuration method

workbench config --mode EcsRamRole

Enter the following as prompted:

  • RAM Role Name: The name of the RAM role attached to the instance. Can be left empty. When empty, the CLI automatically detects the role currently attached to the instance through IMDS (consistent with the optional --ram-role-name behavior of the official Alibaba Cloud CLI).

  • IMDSv2 hardening mode (y/n): The default is y (enables IMDSv2 hardening). If the instance is older and does not support IMDSv2, answer n to fall back to IMDSv1.

After the configuration is complete, use the commands as usual. Credential retrieval and refresh are fully automatic.

Configuration result preview

After completing the configuration, you can verify the credential configuration result by checking ~/.workbench/config.json.

Configuration file fields:

  • mode: Fixed value EcsRamRole

  • role_name (Optional): Leave empty to auto-detect

  • disable_imds_v1 (Optional): Omit or true means IMDSv2 hardening (default); false means IMDSv1 fallback is allowed

Complete configuration examples are as follows:

  • Minimal configuration example (automatic role detection + IMDSv2 hardening):

    {
      "current": "default",
      "profiles": {
        "default": {
          "mode": "EcsRamRole"
        }
      }
    }
  • Specify a role name and allow IMDSv1 fallback:

    {
      "current": "default",
      "profiles": {
        "default": {
          "mode": "EcsRamRole",
          "role_name": "ECSAdmin",
          "disable_imds_v1": false
        }
      }
    }

Reuse Alibaba Cloud CLI credentials (AliyunCLI)

When the Alibaba Cloud CLI is installed and configured on your machine, you can reuse its credential configuration directly without storing a separate AccessKey ID and AccessKey secret in Workbench.

Prerequisites

  • The Alibaba Cloud CLI is installed and configured (aliyun configure).

  • The configuration file is located at ~/.aliyun/config.json, or specified through ALIBABA_CLOUD_CONFIG_FILE. Workbench reads only this configuration file and does not modify its content.

Note

Alibaba Cloud CLI modes such as AK, StsToken, RamRoleArn, EcsRamRole, OIDC, CloudSSO, OAuth, and ChainableRamRoleArn are supported. For dynamic credentials (such as `RamRoleArn`), temporary Security Token Service tokens are refreshed automatically.

Configuration method

workbench config --mode AliyunCLI

Enter the following as prompted:

  • aliyun_profile(Optional): The name of the Alibaba Cloud CLI profile to reuse. If left empty, the current Alibaba Cloud CLI profile is used.

Configuration result preview

After completing the configuration, you can verify the credential configuration result by checking ~/.workbench/config.json. A complete configuration example is as follows:

{
  "current": "default",
  "profiles": {
    "default": {
      "mode": "AliyunCLI",
      "aliyun_profile": "wb-sub-01"
    }
  }
}

Upgrade Workbench CLI

Workbench CLI supports one-step self-upgrade. Run the following command to upgrade to the latest version:

workbench upgrade

The upgrade process automatically downloads and verifies the binary of the latest version and replaces the current version.

Note

If the binary is installed in a directory that requires administrator privileges (for example, /usr/local/bin on Linux or macOS), use sudo workbench upgrade.

Uninstall

Workbench CLI does not register a system service or modify system configurations. To uninstall it, stop the daemon, delete the binary, and (optionally) delete the local configuration directory.

Linux or macOS

Run the following commands in order:

workbench daemon stop
sudo rm -f /usr/local/bin/workbench
rm -rf ~/.workbench

The third command (which deletes ~/.workbench) is optional and removes all local credentials and configuration files.

Windows

Run the following commands in order in PowerShell:

workbench daemon stop
Remove-Item "$env:ProgramFiles\workbench" -Recurse -Force

# Delete the item created during installation in the Cloud Assistant scenario: shim
Remove-Item "$env:SystemRoot\System32\workbench.cmd" -Force -ErrorAction SilentlyContinue

Remove-Item "$env:USERPROFILE\.workbench" -Recurse -Force

# Remove the workbench path that the installation script (remote desktop scenario) added to the user PATH
$path = [Environment]::GetEnvironmentVariable("Path", "User")
if ($path -match "workbench") {
    $cleaned = ($path -split ";" | Where-Object { $_ -notmatch "workbench" }) -join ";"
    [Environment]::SetEnvironmentVariable("Path", $cleaned, "User")
}

Deleting the .workbench directory is optional and removes all local credentials and configuration files.

Note

The preceding commands clean up only the local CLI and the local credentials.The RAM user and the AccessKey in the cloud are not deleted. To remove them as well, log on to the RAM console and delete the corresponding RAM user or disable the AccessKey.

FAQ

Running workbench after installation returns command not found

Cause: The directory that the installation script appended to PATH has not taken effect in the current shell session.

Solution:

  • Linux or macOS: Reopen the terminal, or run source ~/.bashrc (or ~/.zshrc), or use the absolute path /usr/local/bin/workbench version to verify.

  • Windows: Close and reopen the PowerShell window.

Running workbench config returns a configuration file permission error

Cause: The CLI rejects ~/.workbench/config.json if its permissions are too broad (for example, 0644 or group-readable) to prevent other users on the same machine from reading your credentials.

Solution: On Linux or macOS, run the following command to correct the permissions:

chmod 600 ~/.workbench/config.json

workbench list ecs returns InvalidAccessKeyId.NotFound or IncompleteSignature

Cause: Usually one of the following:

  • The AccessKey ID or AccessKey secret entered during configuration is incorrect (for example, it has leading or trailing spaces, or it was not copied completely).

  • The corresponding AccessKey has been disabled or deleted in the RAM console.

Solution: Re-run workbench config, and verify that the AccessKey ID and AccessKey secret belong to the same pair, are complete, and contain no extra spaces; or confirm in the RAM console that the AccessKey status is Enabled.

Verify the installation package

If the installation package is obtained through other channels (such as an offline package or an internal mirror), verify the package’s integrity and security by calculating its SHA256 value and comparing it with the checksum provided by the official source.

Linux or macOS

Run the following command to calculate the SHA256 checksum of the installation package.

shasum -a 256 workbench-linux-amd64.tar.gz
# You could also use this command on Linux:sha256sum workbench-linux-amd64.tar.gz

Windows

Run the following command to calculate the SHA256 checksum of the installation package.

Get-FileHash .\workbench-windows-amd64.zip -Algorithm SHA256

Compare the output with the corresponding value in the SHA256 column in the table below. If they match, the package is intact and has not been tampered with.

v1.0.4 checksum

Platform

Installation package

SHA256

macOS amd64

workbench-darwin-amd64.tar.gz

4db6730792ba729975b097cc2ca4dafa92dca8e0a2733a99fedce3edc90c1408

macOS arm64

workbench-darwin-arm64.tar.gz

b37dc8b34a73b86987a7de5ea0666ff7b5586b87aae68caa8662e3964774b870

Linux amd64

workbench-linux-amd64.tar.gz

41ffee737fa6ae9dfea0d8a47ae2b06275b1ff202ad3e0b7efe8eeed8164a2ab

Linux arm64

workbench-linux-arm64.tar.gz

8c72ba59e5c5aab087de5b054d2a8310acdbd5ba37818e0ab8a8d275b580f062

Windows amd64

workbench-windows-amd64.zip

8637da8ed8133ffdb4cfba88e60e809003ea6c39f0cc601d325c871c726d3e41

Note

The checksum applies to the compressed package itself, not to the extracted Workbench binary. The complete checksum file can be found at: https://workbench-cli.oss-cn-hangzhou.aliyuncs.com/releases/v1.0.4/checksums.sha256.

References