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

# SSH

> Mount a remote SSH host as a Mirage filesystem (Node only).

`SSHVFS` opens an SFTP session and mounts the remote root as a filesystem.

> [!NOTE]
>
> Node only. Requires the `ssh2` peer dependency. The browser SDK doesn't ship an SSH client.

## Install

```bash theme={null}
pnpm add @struktoai/mirage-node ssh2
```

## Config

```ts theme={null}
import { MountMode, SSHVFS, Workspace } from '@struktoai/mirage-node'

const ssh = new SSHVFS({
  host: 'jump.example.com',
  username: 'me',
  identityFile: '~/.ssh/id_ed25519',
  root: '/srv/data',
})

const ws = new Workspace({ '/remote': ssh }, { mode: MountMode.READ })
await ws.shell('ls /remote')
```

| Field | Description |
| - | - |
| `host` required | DNS name or IP address of the remote. |
| `hostname` | Address to connect to instead of `host`. |
| `port` default `22` | SSH port. |
| `username` | Login user; unset uses the local user name. |
| `password` secret | Password for password authentication; prefer `identityFile`. |
| `identityFile` | Path to a private key; `~` is expanded. Unset tries the SSH agent and the default keys in `~/.ssh` (`id_ed25519`, `id_ecdsa`, `id_rsa`, `id_dsa`). |
| `privateKey` secret | A private key's own text, such as one a credential pointer reads from a secret store; offered after `identityFile`'s. |
| `passphrase` secret | Passphrase of an encrypted private key, from `identityFile`, `privateKey` or a default key. |
| `root` default `'/'` | Path on the remote that becomes the mount root. |
| `timeout` default `30` | Seconds to wait for the connection to be ready, authentication included. |
| `knownHosts` | Accepted but not applied: this backend does not verify host keys. |

Fields marked secret are redacted in snapshots.

## Mount mode

`read`, `write`, `exec`. Writes flush via SFTP put. Use `MountMode.EXEC` if `python3` or `js` should run scripts from the mount.

For the full set of supported shell commands see the [Python SSH docs](https://docs.mirage.strukto.ai/python/vfs/ssh.md).

## VFS.md

The [VFS.md](https://docs.mirage.strukto.ai/home/setup/vfs-md.md) an agent reads with SSH mounted at `/<path>`.

> [tab] Rendered
>
> ### Virtual Filesystem
>
> | Path | Description |
> | - | - |
> | `/<path>` | `ssh`, write |
>
> #### Supported Unix Commands for VFS
>
> Unix commands work on each path as on a local filesystem, as far as the path supports them:
>
> | Path | Supported |
> | - | - |
> | `/<path>` | Almost all Unix commands. `grep -r` and `rg` ask `ssh` which files may match. `wc -l` asks `ssh` instead of reading a file. |
>
> #### Limitations of Unix Commands for VFS
>
> Where a path differs from a local filesystem:
>
> | Path | Limitations |
> | - | - |
> | `/<path>` | `grep -r`, `find` and `du` stop after 1000 files; a glob matching more, `tar -c`, `cp -r` and `rm -r` are refused. |
>
> Run `man <cmd>` or `<cmd> --help` for one command's usage.

> [tab] Raw
>
> ```markdown theme={null}
> ---
> name: workspace-filesystem
> description: The virtual filesystem layout of this workspace.
> ---
>
> # Virtual Filesystem
>
> | Path | Description |
> | --- | --- |
> | `/<path>` | `ssh`, write |
>
> ## Supported Unix Commands for VFS
>
> Unix commands work on each path as on a local filesystem, as far as the path supports them:
>
> | Path | Supported |
> | --- | --- |
> | `/<path>` | Almost all Unix commands. `grep -r` and `rg` ask `ssh` which files may match. `wc -l` asks `ssh` instead of reading a file. |
>
> ## Limitations of Unix Commands for VFS
>
> Where a path differs from a local filesystem:
>
> | Path | Limitations |
> | --- | --- |
> | `/<path>` | `grep -r`, `find` and `du` stop after 1000 files; a glob matching more, `tar -c`, `cp -r` and `rm -r` are refused. |
>
> Run `man <cmd>` or `<cmd> --help` for one command's usage.
> ```

## Integration

What SSH answers through its own API, so fewer files are read. [Integration](https://docs.mirage.strukto.ai/home/integration/overview.md) explains each command.

| Command | On SSH |
| - | - |
| `grep -r`, `rg` | `grep` on the server, for any text. It misses nothing. |
| `wc -l` | `wc -l` on the server |
| `tail -f` | `tail -f` on the server |
| `md5sum`, `sha256sum` and the other hash commands | The matching sum tool on the server |
| `find`, `du`, `ls -R`, `tree` | One `find` on the server |

The [Python SSH docs](https://docs.mirage.strukto.ai/python/vfs/ssh.md#integration) list when each search answers and what it can miss.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.