# Confirm sensitive CLI commands

Confirm deletes, secret reads and access changes from the CLI with Touch ID, a security key, Windows Hello or a passkey, and choose when your own CLI sessions ask.

A CLI session that must confirm asks for your device key or your passkey before a sensitive action
when your last confirmation is older than your confirmation window: five minutes unless you choose
more (up to 60, or less than your organization's cap). Console sessions and access keys never ask.

These actions are sensitive:

- every action marked destructive in the `::iam-actions` tables of the guides;
- reads of secret material or source code (the actions marked sensitive);
- every IAM change;
- actions that hand out another credential: `git:CreateAccessToken`, `s3:CreateAccessKey`,
  `s3:CreateTemporaryCredentials`, `eks:GetClusterAdminCredentials`, `ecr:GetAuthorizationToken`,
  `npm:GetAuthorizationToken` and `ci:CreateIdToken`.

A session confirms when your organization requires Touch ID or a passkey (see
[Require Touch ID or a passkey for the CLI](require-touch-id-for-the-cli.md)), and otherwise as your
own setting says: by default, sessions opened with a device key (Touch ID, a security key, Windows
Hello) confirm and browser sessions do not.

## Prerequisites

- A CLI session from `dcloud login` (see [Sign in the CLI](sign-in-the-cli.md)).
- A device enrolled with a passkey that can confirm (a Mac with Touch ID, a security key with a
  PIN, a PC with Windows Hello), or a passkey on your account (see [Add a passkey](add-a-passkey.md)).
- No IAM action is needed to confirm or to change your own setting. The action itself still needs
  its permission: after the confirmation, a refused action is answered 403 as usual. Most actions
  are checked against your policies before a confirmation is asked; some sensitive reads are
  refused with a plain 403 while a confirmation is due, and the CLI then asks for one before it
  learns whether your policies allow the read.

## Confirm a command

**CLI**
1. Run the command. When a confirmation is due, the CLI says the action needs a fresh confirmation.
2. When the profile has an enrolled device key, confirm with it: the Touch ID prompt on a Mac (it
   names the action), a touch of the security key and its PIN on Linux, the Windows Hello prompt on
   Windows. When the key cannot confirm (enrolled without a passkey, or a security key without a
   PIN), the prompt still appears, the CLI then prints
   `This device key cannot confirm it is you (a software key, or one enrolled without a passkey). Confirm in the browser with your passkey.`
   and goes on in the browser. In the browser, and on a profile without a device key, the CLI
   prints a code and the `/activate` address: on the page [Approve a device](/activate), which
   shows **Confirm a command**, choose **Confirm with passkey** and confirm with your passkey.

The CLI sends the command again and prints its result.

**Console:** not available. The console never asks for a confirmation.

With an enrolled Mac or Windows PC that can confirm, its prompt appears even for a command run from
a script. When the confirmation would go to the browser, a command without a terminal cannot open
it and fails with `… needs you to confirm it, and there is nobody at this terminal`. Confirm once in a terminal first;
the commands within your confirmation window run without asking:

```sh
dcloud auth verify
```

`dcloud auth whoami` shows when you last confirmed under **Confirmed**.

For most actions, the API answers a due confirmation with 403, the code `STEP_UP_REQUIRED` and, for
example,
`secrets:DeleteSecret needs you to confirm it with Touch ID or a passkey (last confirmation more than 5 minutes ago).`
Some sensitive reads answer a plain 403 `Forbidden` instead.

A device that an administrator blocked in the organization cannot confirm there: the CLI prints
`An administrator blocked this device for the organization` and confirms in the browser instead.
A confirmation in the browser needs a passkey. Without one on your account, the page says
`Your organization or your account requires a passkey here, and your account has none yet.` and
offers no approval.

## Choose when your CLI sessions ask

**Console**
1. Open [My account](/account). Under **Command line sign-in**, find **Confirm sensitive commands**.
2. Choose one:
   - **When I sign in with Touch ID, a security key or Windows Hello (default)**: sessions opened with a device key confirm, browser
     sessions do not.
   - **Always, and only sign in with one of those or a passkey**: every CLI session of yours confirms,
     signing in needs a device key that verifies you or a passkey, and connecting an app (an AI
     assistant over MCP) needs a passkey.
   - **Never**: no confirmations.
3. For any choice but **Always, and only sign in with one of those or a passkey**, confirm with your
   passkey.

The setting is saved at once, and the console says **Setting changed.** It applies in every
organization you belong to.

**CLI:** not available. The CLI has no command for this setting.

While your organization requires Touch ID or a passkey, the choice shows **Always, and only sign in with one of those or a passkey** and cannot be changed. Choosing **Always, and only sign in with one of those or a passkey** stops your CLI sessions that were opened without Touch ID or a passkey, and
the apps you connected without a passkey, at their next request. Without a passkey on your account,
loosening the setting is refused with 400 `Your account has no passkey yet`.

## Choose how long a confirmation lasts

1. Open [My account](/account) and go to **Command line sign-in**.
2. Under **A confirmation lasts**, choose 5 (the default), 10, 15, 30 or 60 minutes. A longer time asks
   for your passkey first; a shorter one does not. Times above your organization's cap cannot be
   chosen.

`dcloud auth whoami` shows the time under **Confirmation lasts**.

## Related

- [Sign in the CLI](sign-in-the-cli.md)
- [End CLI sessions](end-cli-sessions.md)
- [Require Touch ID or a passkey for the CLI](require-touch-id-for-the-cli.md)
