> ## Documentation Index
> Fetch the complete documentation index at: https://docs.microsandbox.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# SSH

> Run SSH commands with the Ruby SDK.

See [SSH](/sandboxes/ssh) for connection behavior.

## Sandbox

#### <span className="msb-recv">sandbox.</span><span className="msb-hn">ssh\_exec()</span>

```ruby theme={null}
sandbox.ssh_exec(command, **options) # => Hash
```

<Accordion title="Example">
  ```ruby theme={null}
  result = sandbox.ssh_exec("uname -a", inactivity_timeout: 60)
  puts result["stdout"]
  ```
</Accordion>

Run a command over SSH and collect its output. Managed settings take precedence over the supplied timeout. Ruby does not expose interactive SSH or SFTP sessions.

<p className="msb-label">Parameters</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>command</code><span className="msb-type">String</span></div>
    <div className="msb-param-desc">Command to execute over SSH.</div>
  </div>

  <div className="msb-param">
    <div className="msb-param-key"><code>inactivity\_timeout</code><span className="msb-type">Numeric</span></div>
    <div className="msb-param-desc">Optional timeout in seconds. Omit to inherit global configuration; use 0 to disable it.</div>
  </div>
</div>

<p className="msb-label">Returns</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><span className="msb-type">Hash</span></div>
    <div className="msb-param-desc">Collected output and exit status, with string keys.</div>
  </div>
</div>

<p className="msb-label">Result fields</p>

<div className="msb-params">
  <div className="msb-param">
    <div className="msb-param-key"><code>"stdout"</code><span className="msb-type">String</span></div>
    <div className="msb-param-desc">Standard output bytes</div>
  </div>

  <div className="msb-param">
    <div className="msb-param-key"><code>"stderr"</code><span className="msb-type">String</span></div>
    <div className="msb-param-desc">Standard error bytes</div>
  </div>

  <div className="msb-param">
    <div className="msb-param-key"><code>"exit\_code"</code><span className="msb-type">Integer</span></div>
    <div className="msb-param-desc">Exit status</div>
  </div>

  <div className="msb-param">
    <div className="msb-param-key"><code>"success"</code><span className="msb-type">Boolean</span></div>
    <div className="msb-param-desc">Whether the exit status is zero</div>
  </div>
</div>
