Skip to main content

Overview

The m87 CLI provides several commands for accessing and monitoring remote devices. These commands allow you to open interactive shells, execute commands remotely, check device status, and audit device access logs.

Shell Command

Open a persistent interactive shell session on a remote device.

Syntax

m87 <device> shell

Description

The shell command provides a full interactive shell with PTY support, similar to SSH. It opens a persistent bash session on the remote device with full terminal capabilities.

Features

  • Full PTY support - Colors, cursor control, and terminal formatting
  • TUI applications - Works with vim, htop, less, nano, and other terminal UI apps
  • Default shell - Uses the user’s default shell defined in $SHELL
  • Easy exit - Press Ctrl+D to exit the shell session

Examples

m87 rpi shell

# You're now in a remote shell
pi@raspberrypi:~ $ ls -la
pi@raspberrypi:~ $ htop
pi@raspberrypi:~ $ vim config.yaml
pi@raspberrypi:~ $ exit
For scripting and automation, use exec instead of shell. The shell command is designed for interactive work only.

Shell vs Exec Comparison

Featureshellexec
Persistent session✓ Yes✗ No
Multiple commands✓ YesSingle command
Interactive apps✓ AlwaysWith -it flags
Scripting✗ No✓ Yes

Exec Command

Execute commands on remote devices with optional stdin forwarding and TTY support.

Syntax

m87 <device> exec [OPTIONS] -- <COMMAND>

Options

FlagDescription
-i, --stdinKeep stdin open for responding to prompts
-t, --ttyAllocate a pseudo-TTY for TUI applications

Execution Modes

FlagsModeUse Case
(none)Output onlySimple commands, scripts
-iStdin forwardingSimple prompts (Y/n), piped input
-tTTY read-onlyColored output, watch mode
-itFull TTYsudo, TUI apps (vim, htop, less)

Examples

# Check disk usage
m87 rpi exec -- df -h

# Update packages (needs TTY for sudo password)
m87 rpi exec -it -- 'sudo apt update && sudo apt upgrade'

# View system logs
m87 rpi exec -- journalctl -n 100

Shell Quoting

Commands are interpreted by your local shell first. Use single quotes to send commands literally to the remote device.
# ❌ Local shell expands $(...)
m87 rpi exec -- docker kill $(docker ps -q)  # Runs docker ps -q locally!

# ✓ Single quotes send literally to remote
m87 rpi exec -- 'docker kill $(docker ps -q)'  # Expands on remote

Ctrl+C Behavior

ModeCtrl+C Effect
No flags / -iTerminates connection, exits with code 130
-tNo effect (stdin not connected)
-itSent to remote app (e.g., cancel in vim)
TTY flag behavior: The -t flag without -i allocates a TTY for output formatting but does not connect stdin. This means keyboard input (including Ctrl+C) has no effect. Use -t alone for commands that need colored/formatted output but no interaction.

Process Cleanup

When the connection closes (Ctrl+C, network drop, etc.), the remote process is automatically terminated. No orphaned processes are left on the device.

Status Command

Check the status of a remote device including health, crashes, and incidents.

Syntax

m87 <device> status

Description

Displays comprehensive status information about the device, including:
  • Connection status (online/offline)
  • System health metrics
  • Recent crashes or errors
  • Active incidents
  • Runtime information

Example

m87 rpi-garage status
Use m87 devices list to see the status of all devices at once.

Audit Command

View audit logs showing who interacted with the device and when.

Syntax

m87 <device> audit [OPTIONS]

Options

FlagDefaultDescription
--since <DATE>-Filter logs from this RFC 3339 date (e.g., 2026-01-31 or 2026-01-31T13:00:00)
--until <DATE>-Filter logs up to this RFC 3339 date
--max <NUM>100Maximum number of logs to return
--detailsfalseShow detailed information for each audit entry

Examples

# View recent audit logs
m87 rpi audit

Audit Log Information

Audit logs capture:
  • User access events (shell, exec, etc.)
  • Command executions
  • File transfers
  • Port forwarding sessions
  • Deployment operations
  • Timestamps and user identifiers
Audit logs help with compliance, security monitoring, and troubleshooting device access issues.