After you install Workbench CLI on a Linux, macOS, or Windows machine, attach a least-privilege permission policy to a RAM user, then create and configure an AccessKey to get up and running out of the box. In production environments, you can switch to the RamRoleArn, CredentialsCmd, or CredentialsURI mode to enable automatic credential refresh with minimum permissions.
Limits
Operating system of the target instance: Workbench CLI supports connecting only to Linux instances (over the SSH protocol). It does not support connecting to Windows instances.
Operating system of the local machine: Workbench CLI itself can run on Linux, macOS (amd64 / arm64), and Windows (amd64).
Network connectivity: The local machine must be able to access
*.aliyuncs.comand the Workbench backend WebSocket endpoint.
Windows instances are currently not supported by Workbench CLI. To connect to a Windows instance, see Connect to an instance by using Workbench.
Step 1: Install Workbench CLI
Choose the installation command based on the operating system of your local machine. The installation script automatically detects the architecture (amd64 / arm64), downloads the binary from the OSS CDN, verifies its SHA256 checksum, and installs it to the system default 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 | bashAfter the installation is complete, 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
In PowerShell, run the following command to install the latest version of Workbench CLI.
irm https://workbench-cli.oss-cn-hangzhou.aliyuncs.com/install.ps1 | iexAfter the installation is complete, the binary is located at C:\Program Files\workbench\. The installation script automatically configures the PATH environment variable. If you install it in a desktop or Remote Desktop (RDP) session, you must log off and log on again for the PATH to take effect.
Verify the Installation
After the installation is complete, run the following command to verify it:
workbench versionUnder normal conditions, the command outputs the current version number, commit ID, and build date. If the message command not found is displayed, the PATH has usually not taken effect. You can perform the following operations:
Linux / macOS: Open a new terminal window, or run
source ~/.bashrc(or~/.zshrc) and try again.Windows: Close and reopen the PowerShell window to let the new PATH take effect.
Step 2: Prepare an AccessKey with the Minimum 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 local CLI in the next step. The recommended process is: create a RAM user → grant minimum permissions → create an AccessKey for the RAM user.
We do not recommend using the AccessKey ID and AccessKey Secret of your Alibaba Cloud account to configure the CLI. The AccessKey of the Alibaba Cloud account has permissions to operate on all cloud resources under the account. If it is leaked, all your assets are exposed. Always use the AccessKey of a RAM user that has the minimum permissions.
If you already have a RAM user that has the minimum permissions for Workbench CLI, you can skip Steps 1 to 3 and start from Step 4: Create an AccessKey for the RAM user.
Create a RAM user. Log on to the RAM console, go to the page, and click Create User. On the creation page, enter the Logon Name and Display Name, and then click OK.
Do not create an AccessKey at this point. The AccessKey is created together after permissions are granted in Step 4.
Create a custom permission policy. On the page of the RAM console, click Create Policy, switch to the Script mode/JSON mode, paste the following JSON, and then click OK.
"Version": "1", "Statement": [ { "Effect": "Allow", "Action": [ "ecs-workbench:*" ], "Resource": "*" }, { "Effect": "Allow", "Action": [ "ecs:DescribeInstances" ], "Resource": "*" }, { "Effect": "Allow", "Action": "ram:CreateServiceLinkedRole", "Resource": "*", "Condition": { "StringEquals": { "ram:ServiceName": "workbench.ecs.aliyuncs.com" } } } ]{The purpose of each Action in the policy is as follows:
Action
Purpose
ecs:DescribeInstancesAllows
workbench list ecsto query the instance list.ecs:DescribeCloudAssistantStatusChecks the Cloud Assistant agent status of the target instance.
ecs:StartTerminalSessionEstablishes a terminal session with an ECS instance.
ecs-workbench:LoginECSInstanceEnables password-free logon over the Workbench channel (used by connect, exec, upload, and download).
ecs-workbench:ChatMessagesThe permission required by the in-session AI agent assistant (
/agentmode).ecs-workbench:EndSessionsCloses Workbench sessions (called by
session closeand during automatic session cleanup).ram:CreateServiceLinkedRoleCreates the Workbench service-linked role on first use. The
Conditionrestricts creation to only the service-linked role for theworkbench.ecs.aliyuncs.comservice.By default, the policy grants access to all instances. To narrow it to specific instances, apply an instance ARN only to the actions that support instance-level authorization (note that the two action groups use different ARN formats). Split them into separate
Statementblocks and modify theResource:// ecs-workbench:LoginECSInstance "Resource": "acs:ecs:<region>:<account-id>:ecs/<instance-id>" // ecs:DescribeInstances / DescribeCloudAssistantStatus / StartTerminalSession "Resource": "acs:ecs:<region>:<account-id>:instance/<instance-id>"Noteecs-workbench:ChatMessagesandram:CreateServiceLinkedRoledo not support narrowing by instance ARN. Keep"Resource": "*"for them.Grant the policy to the RAM user. Go to the details page of the RAM user created in Step 1, switch to the Permissions tab, click Grant Permission, select the custom policy created in the previous step, and complete the authorization. For more information, see Grant permissions to a RAM user.
Create an AccessKey for the RAM user. On the tab of the RAM user details page, click Create AccessKey. In the dialog that appears, select Use AccessKey in CLI, select I confirm that I must create an AccessKey, and then click Continue to create. For more information, see Create an AccessKey pair.
ImportantThe AccessKey Secret is displayed only once when it is created and cannot be viewed again after the page is closed. Immediately save the AccessKey ID and Secret to a password manager or key vault. If you lose them, you can only create a new AccessKey.
An AccessKey is a long-term credential. Once leaked, it can be abused over a long period. In production environments, we recommend that you switch to an automatically refreshing credential mode such as RamRoleArn immediately after you complete the configuration in Step 3. For more information, see the More configuration methods section of this document.
Step 3: Configure the AccessKey in the Local CLI
Run the following command, and enter the AccessKey ID and AccessKey Secret obtained in Step 2 as prompted.
workbench configAfter 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). The following is an example of the file content:
{
"current": "default",
"profiles": {
"default": {
"mode": "AK",
"access_key_id": "LTAI...",
"access_key_secret": "..."
}
}
}Run the following command to verify whether the connection is established (replace cn-hangzhou with your actual region):
workbench list ecs -r cn-hangzhouUnder normal conditions, the command returns the list of instances in the region. If an error such as InvalidAccessKeyId or NoPermission is returned, see the FAQ section of this document.
(Optional) Set the interface language
Workbench CLI supports Chinese (zh) and English (en) for the interface language. The default is Chinese. Run the following commands to switch:
workbench config set language en # Switch to English
workbench config set language zh # Switch back to ChineseYou can also set it during the workbench config interactive flow, or directly edit ~/.workbench/config.json to add the language field to the corresponding profile:
{
"current": "default",
"profiles": {
"default": {
"mode": "AK",
"language": "en"
}
}
}The change takes effect the next time you connect. 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, you can use the profile feature to avoid repeatedly reconfiguring. All profiles are saved in the same ~/.workbench/config.json file, and the current field marks the active profile.
workbench config --profile prod # Create or edit the profile named prod
workbench config list # List all profiles (* marks the active one)
workbench config get --profile prod # Show the details of a specific profile
workbench config switch --profile prod # Switch the active profile
workbench config delete --profile old # Delete a profile (cannot delete the active one)
workbench exec -i i-xxx -c "hostname" --profile prod # Use a specific profile for this command onlyThe following is an example of the multi-profile structure in config.json:
{
"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"
}
}
}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 first run, storing the existing credentials in a profile named default. No manual action is required.
More Configuration Methods
A long-term AccessKey is a long-term credential. Once leaked, it can be abused over a long period. In production environments or when you have stricter security requirements, we recommend that you switch to one of the following four modes:
Mode | Scenario | Configuration command |
AK (Steps 2 to 3 in this document) | A long-term AccessKey. For quick start in development environments. |
|
StsToken | Temporary security credentials (AccessKey + STS Token). Suitable for scenarios where you already have STS temporary credentials. |
|
RamRoleArn | Recommended for production environments: A low-privilege AccessKey assumes a high-privilege RAM role, and STS temporary credentials are automatically refreshed. |
|
CredentialsCmd | Dynamically obtains credentials by running an external program, integrating with your existing credential distribution or key management system. |
|
CredentialsURI | Dynamically obtains credentials by using an HTTP service (a metadata service, a sidecar, and so on). |
|
Use STS Temporary Credentials (StsToken)
Authenticate directly by using temporary security credentials obtained through STS (AccessKey ID + AccessKey Secret + STS Token). This mode is suitable for scenarios where you already hold temporary credentials. Temporary credentials have an expiration time and must be reconfigured after they expire. If you need automatic refresh, use the RamRoleArn mode instead.
workbench config --mode StsTokenAs prompted, enter the temporary AccessKey ID, AccessKey Secret, and STS Token in sequence. The following is an example of ~/.workbench/config.json:
{
"current": "default",
"profiles": {
"default": {
"mode": "StsToken",
"access_key_id": "STS.LTAI...",
"access_key_secret": "...",
"sts_token": "..."
}
}
}Use a RAM Role (RamRoleArn)
A low-privilege AccessKey assumes a high-privilege RAM role. The CLI automatically calls STS AssumeRole to obtain temporary credentials and refreshes them automatically before they expire. The credentials are not persisted as a long-term AccessKey, which is suitable for production environments.
workbench config --mode RamRoleArnAs prompted, enter the low-privilege AccessKey ID, AccessKey Secret, the ARN of the RAM role to assume (format: acs:ram::<account-id>:role/<role-name>), and the session identifier (default: workbench-session). The following is an example of ~/.workbench/config.json:
{
"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"
}
}
}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?.
Use an External Command Credential (CredentialsCmd)
Credentials are dynamically obtained by running an external program. This mode is suitable for integrating with your existing credential distribution or key management system. Before each API request, the CLI runs the configured command and parses its stdout as the credentials.
workbench config --mode CredentialsCmdAs prompted, enter the full path and parameters of the external command. The exit code of the external command must be 0, and its stdout output must be one of the following two JSON formats:
// Long-term AccessKey
{
"mode": "AK",
"access_key_id": "<AccessKeyID>",
"access_key_secret": "<AccessKeySecret>"
}
// STS temporary credentials
{
"mode": "StsToken",
"access_key_id": "<AccessKeyID>",
"access_key_secret": "<AccessKeySecret>",
"sts_token": "<SecurityToken>"
}The external program only needs to return credentials to stdout in the JSON format shown above. This lets you integrate with your existing credential distribution tool or key management system.
Use a Credential URI (CredentialsURI)
Temporary credentials are obtained by sending a GET request to an HTTP service. This mode is suitable for scenarios such as a self-built credential distribution service, the ECS instance metadata service, and a sidecar credential endpoint. The CLI automatically re-obtains credentials before they expire.
workbench config --mode CredentialsURIAs prompted, enter the HTTP or HTTPS address of the credential service. The credential service must return HTTP 200, and the response body must be:
{
"Code": "Success",
"AccessKeyId": "<AccessKeyID>",
"AccessKeySecret": "<AccessKeySecret>",
"SecurityToken": "<SecurityToken>",
"Expiration": "2026-01-01T12:00:00Z"
}The Code field must be exactly Success (case-sensitive). The Expiration field uses the ISO 8601 format, based on which the CLI automatically re-obtains credentials before they expire.
The following is an example of ~/.workbench/config.json:
{
"current": "default",
"profiles": {
"default": {
"mode": "CredentialsURI",
"credentials_uri": "http://localhost:8080/credentials"
}
}
}Upgrade Workbench CLI
Workbench CLI supports one-command self-upgrade. Run the following command to upgrade to the latest version:
workbench upgradeThe upgrade automatically downloads and verifies the latest binary and replaces the current version.
If the binary is installed in a directory that requires administrator privileges (for example, /usr/local/bin on Linux/macOS), use sudo workbench upgrade.
Uninstall
Workbench CLI does not register a system service or modify system configurations. To uninstall it, you only need to stop the daemon, delete the binary, and optionally delete the local configuration directory.
Linux or macOS
Run the following commands in sequence:
workbench daemon stop
sudo rm -f /usr/local/bin/workbench
rm -rf ~/.workbenchThe third command (which deletes ~/.workbench) is optional and is used to clear all local credentials and configuration files.
Windows
In PowerShell, run the following commands in sequence:
workbench daemon stop
Remove-Item "$env:ProgramFiles\workbench" -Recurse -Force
# Remove the shim created during Cloud Assistant-based installation
Remove-Item "$env:SystemRoot\System32\workbench.cmd" -Force -ErrorAction SilentlyContinue
Remove-Item "$env:USERPROFILE\.workbench" -Recurse -Force
# Clean up the workbench path added to the user PATH by the installation script (Remote Desktop scenarios)
$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 is used to clear all local credentials and configuration files.
The preceding commands clean up only the local CLI and local credentials. The RAM user and AccessKey in the cloud are not deleted. To clean them up as well, go to the RAM console to 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 the PATH has not yet taken effect in the current shell session.
Solution:
Linux / macOS: Open a new terminal, run
source ~/.bashrc(or~/.zshrc), or directly use the absolute path/usr/local/bin/workbench versionto verify.Windows: Close and reopen the PowerShell window.
Running workbench config Returns a Configuration File Permission Error
Cause: The CLI rejects a ~/.workbench/config.json file with overly broad permissions (for example, permissions of 0644 or group-readable), to prevent the credentials from being read by other users on the same machine.
Solution: On Linux / macOS, run the following command to correct the permissions:
chmod 600 ~/.workbench/config.jsonworkbench list ecs Returns InvalidAccessKeyId.NotFound or IncompleteSignature
Cause: This is usually one of the following:
The AccessKey ID or Secret entered during configuration is incorrect (for example, it has leading or trailing spaces or was not fully copied).
The corresponding AccessKey has been disabled or deleted in the RAM console.
Solution: Run workbench config again and make sure the AccessKey ID and Secret are a matching pair, complete, and free of extra spaces; or confirm in the RAM console that the AccessKey status is Enabled.
References
Connect to an instance by using Workbench CLI: The parent topic, which covers tool positioning, the capability matrix, and quick start.
Manage ECS instances by using Workbench CLI: Detailed descriptions of each command and common scenarios.
Operate ECS instances by using Workbench CLI in AI agents: Integrate Workbench CLI into AI programming tools.