alpacon exec
Execute a command directly on a remote server without opening an interactive terminal session. This is useful for running one-off commands, automation scripts, or retrieving output from a server.
alpacon exec [USER@]SERVER COMMAND... [flags]
Options
-h, --help help for exec
-u, --username string Specify username
-g, --groupname string Specify groupname
Examples
Execute a command on a server:
alpacon exec my-server "ls -la /var/log"
Execute as a specific user:
alpacon exec admin@my-server "cat /etc/hostname"
alpacon exec -u admin my-server "cat /etc/hostname"
Execute with a specific group:
alpacon exec -g developers my-server "whoami"
Run multiple commands:
alpacon exec my-server "df -h && free -m"
MFA authentication
When executing commands as a system account (e.g., root@my-server), your workspace’s authentication policy may require additional MFA verification. The CLI MFA flow is the same as alpacon websh—see websh MFA authentication for details.
API token ACLs
When using an API token, the token must have ACL rules for each command you intend to execute. Interactive websh sessions are not restricted by command ACLs, but exec commands always require matching ACL rules.
# Allow the commands this token can run on servers
alpacon token acl add --token=my-token --command="df *"
alpacon token acl add --token=my-token --command="cat /etc/hostname"
See Token ACL management for details on wildcard patterns.