# rustonbsd/iroh-ssh architecture

> Architecture diagram of the GitHub repository rustonbsd/iroh-ssh, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rustonbsd/iroh-ssh
- Repository: https://github.com/rustonbsd/iroh-ssh

## Overview

iroh-ssh lets a user reach an SSH daemon by endpoint ID without exposing a port or configuring a VPN. The client workflow parses a target, starts the local OpenSSH client with an iroh-ssh ProxyCommand, and the proxy establishes an Iroh connection; on the server, the tunnel forwards streams to localhost SSH. Server, identity/info, relay configuration, and Linux/Windows service management are additional product capabilities. The graph reflects shown calls and README-documented behavior; platform service runtime details are only partially excerpted.

Main entry points: [`src/api.rs`](https://github.com/rustonbsd/iroh-ssh/blob/main/src/api.rs) (Mode orchestration), [`src/cli.rs`](https://github.com/rustonbsd/iroh-ssh/blob/main/src/cli.rs) (Command arguments), [`src/service/mod.rs`](https://github.com/rustonbsd/iroh-ssh/blob/main/src/service/mod.rs) (Platform dispatch), [`src/ssh.rs`](https://github.com/rustonbsd/iroh-ssh/blob/main/src/ssh.rs) (Tunnel proxy)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI entry"]
  node_cli["Command arguments<br/>[cli.rs]"]
  node_main["Command dispatch<br/>[main.rs]"]
  node_api["Mode orchestration<br/>[api.rs]"]
end

subgraph group_connection["SSH connection"]
  node_client["SSH client launch<br/>[ssh.rs]"]
  node_proxy["Tunnel proxy<br/>[ssh.rs]"]
  node_server["Tunnel server<br/>[ssh.rs]"]
end

subgraph group_identity["Identity and info"]
  node_keys[("SSH identity keys<br/>[ssh.rs]")]
  node_info["Endpoint information<br/>[api.rs]"]
end

subgraph group_services["Service management"]
  node_service_api["Service commands<br/>[api.rs]"]
  node_service_dispatch["Platform dispatch<br/>[mod.rs]"]
  node_linux_service["Linux service<br/>[linux.rs]"]
  node_windows_service["Windows service<br/>[windows.rs]"]
  node_firewall["Firewall rules<br/>[firewall.rs]"]
end

node_user(("Operator"))
node_iroh{{"Iroh P2P network"}}
node_ssh_client["OpenSSH client"]
node_sshd["Local SSH daemon"]

node_user -->|"supplies command"| node_cli
node_cli -->|"parses arguments"| node_main
node_main -->|"dispatches mode"| node_api
node_api -->|"starts SSH"| node_client
node_client -->|"spawns with proxy"| node_ssh_client
node_ssh_client -->|"invokes ProxyCommand"| node_proxy
node_api -->|"builds endpoint connection"| node_proxy
node_proxy -->|"opens QUIC tunnel"| node_iroh
node_iroh -->|"delivers stream"| node_server
node_server -->|"forwards to port"| node_sshd
node_api -->|"starts server mode"| node_server
node_api -->|"loads identity"| node_keys
node_api -->|"reports endpoint"| node_info
node_cli -->|"requests install"| node_service_api
node_service_api -->|"dispatches platform"| node_service_dispatch
node_service_dispatch -->|"selects Linux"| node_linux_service
node_service_dispatch -->|"selects Windows"| node_windows_service
node_windows_service -->|"manages rules"| node_firewall

click node_cli "https://github.com/rustonbsd/iroh-ssh/blob/main/src/cli.rs"
click node_main "https://github.com/rustonbsd/iroh-ssh/blob/main/src/main.rs"
click node_api "https://github.com/rustonbsd/iroh-ssh/blob/main/src/api.rs"
click node_client "https://github.com/rustonbsd/iroh-ssh/blob/main/src/ssh.rs"
click node_proxy "https://github.com/rustonbsd/iroh-ssh/blob/main/src/ssh.rs"
click node_server "https://github.com/rustonbsd/iroh-ssh/blob/main/src/ssh.rs"
click node_keys "https://github.com/rustonbsd/iroh-ssh/blob/main/src/ssh.rs"
click node_info "https://github.com/rustonbsd/iroh-ssh/blob/main/src/api.rs"
click node_service_api "https://github.com/rustonbsd/iroh-ssh/blob/main/src/api.rs"
click node_service_dispatch "https://github.com/rustonbsd/iroh-ssh/blob/main/src/service/mod.rs"
click node_linux_service "https://github.com/rustonbsd/iroh-ssh/blob/main/src/service/linux.rs"
click node_windows_service "https://github.com/rustonbsd/iroh-ssh/blob/main/src/service/windows.rs"
click node_firewall "https://github.com/rustonbsd/iroh-ssh/blob/main/src/service/windows/firewall.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_main,node_api,node_ssh_client toneBlue
class node_client,node_proxy,node_server toneAmber
class node_keys,node_info toneMint
class node_service_api,node_service_dispatch,node_linux_service,node_windows_service,node_firewall toneRose
class node_user,node_iroh,node_sshd toneIndigo
```

## Components

### CLI entry

- [Command arguments](https://github.com/rustonbsd/iroh-ssh/blob/main/src/cli.rs): `src/cli.rs`
- [Command dispatch](https://github.com/rustonbsd/iroh-ssh/blob/main/src/main.rs): `src/main.rs`
- [Mode orchestration](https://github.com/rustonbsd/iroh-ssh/blob/main/src/api.rs): `src/api.rs`

### SSH connection

- [SSH client launch](https://github.com/rustonbsd/iroh-ssh/blob/main/src/ssh.rs): `src/ssh.rs`
- [Tunnel proxy](https://github.com/rustonbsd/iroh-ssh/blob/main/src/ssh.rs): `src/ssh.rs`
- [Tunnel server](https://github.com/rustonbsd/iroh-ssh/blob/main/src/ssh.rs): `src/ssh.rs`

### Identity and info

- [SSH identity keys](https://github.com/rustonbsd/iroh-ssh/blob/main/src/ssh.rs): `src/ssh.rs`
- [Endpoint information](https://github.com/rustonbsd/iroh-ssh/blob/main/src/api.rs): `src/api.rs`

### Service management

- [Service commands](https://github.com/rustonbsd/iroh-ssh/blob/main/src/api.rs): `src/api.rs`
- [Platform dispatch](https://github.com/rustonbsd/iroh-ssh/blob/main/src/service/mod.rs): `src/service/mod.rs`
- [Linux service](https://github.com/rustonbsd/iroh-ssh/blob/main/src/service/linux.rs): `src/service/linux.rs`
- [Windows service](https://github.com/rustonbsd/iroh-ssh/blob/main/src/service/windows.rs): `src/service/windows.rs`
- [Firewall rules](https://github.com/rustonbsd/iroh-ssh/blob/main/src/service/windows/firewall.rs): `src/service/windows/firewall.rs`

### Other components

- **Operator**
- **Iroh P2P network**
- **OpenSSH client**
- **Local SSH daemon**

## Connections

- Operator → Command arguments: supplies command (evidence: `README.md`)
- Command arguments → Command dispatch: parses arguments (evidence: `src/main.rs`)
- Command dispatch → Mode orchestration: dispatches mode (evidence: `src/main.rs`)
- Mode orchestration → SSH client launch: starts SSH (evidence: `src/api.rs`)
- SSH client launch → OpenSSH client: spawns with proxy (evidence: `README.md`)
- OpenSSH client → Tunnel proxy: invokes ProxyCommand (evidence: `README.md`)
- Mode orchestration → Tunnel proxy: builds endpoint connection (evidence: `src/api.rs`)
- Tunnel proxy → Iroh P2P network: opens QUIC tunnel (evidence: `README.md`)
- Iroh P2P network → Tunnel server: delivers stream (evidence: `README.md`)
- Tunnel server → Local SSH daemon: forwards to port (evidence: `src/ssh.rs`)
- Mode orchestration → Tunnel server: starts server mode (evidence: `README.md`)
- Mode orchestration → SSH identity keys: loads identity (evidence: `src/api.rs`)
- Mode orchestration → Endpoint information: reports endpoint (evidence: `README.md`)
- Command arguments → Service commands: requests install
- Service commands → Platform dispatch: dispatches platform (evidence: `src/service/mod.rs`)
- Platform dispatch → Linux service: selects Linux (evidence: `src/service/mod.rs`)
- Platform dispatch → Windows service: selects Windows (evidence: `src/service/mod.rs`)
- Windows service → Firewall rules: manages rules (evidence: `src/service/windows.rs`)
