Run a command as another Linux user (sudo)
exec_asExecute a Linux command as another user via sudo non-interactively, with optional password piped securely through stdin without logging.
Instructions
Run a command non-interactively as another Linux user via sudo -S -p '' -iu <runAs> -- bash -lc <command>. The optional sudoPassword is piped to stdin and is never returned or logged. runAs is strictly validated as a Linux username. WARNING: this performs privileged actions on the remote host.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| runAs | Yes | Target Linux username, e.g. 'appuser'. Strictly validated. | |
| command | Yes | Command to run as the target user. | |
| timeoutMs | No | ||
| sudoPassword | No | Optional sudo password. Piped via stdin; never logged or returned. | |
| connectionName | Yes |