Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions bin/cli/src/command/terminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::{Context, anyhow};
use colored::Colorize;
use komodo_client::{
api::{
read::{ListAllDockerContainers, ListServers},
read::{GetServer, ListAllDockerContainers, ListServers},
terminal::InitTerminal,
},
entities::{
Expand Down Expand Up @@ -138,11 +138,14 @@ async fn get_server(
}

if containers.len() == 1 {
return containers
let server_id = containers
.pop()
.context("Shouldn't happen")?
.server_id
.context("Container doesn't have server_id");
.context("Container doesn't have server_id")?;
let server_name =
client.read(GetServer { server: server_id }).await?.name;
return Ok(server_name);
}

let servers = containers
Expand Down
60 changes: 58 additions & 2 deletions docsite/docs/ecosystem/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

The Komodo CLI, `km`, can be used to:
- Quickly **run executions** and update **resources** and **variables**.
- **Reset user passwords** and elevate users to **Super Admin**.
- **Reset user passwords** and elevate users to **Super Admin**.
- Perform Database **backup**, **restore**, and **copy**.
- **Connect to server / container shell** via Komodo Terminals.

The Komodo Core image comes packaged with the Komodo CLI,
and is available for usage inside running container with `docker exec -it komodo-core km ...`.
Expand All @@ -21,6 +22,61 @@ This way, it inherits the Core database config in order to easily perform backup
- `km x commit my-sync`
- `km set user mbecks super-admin true`
- `km set user mbecks password "temp-password"`
- `km ssh my-server`
- `km connect my-server bash -n my-session`
- `km exec my-container bash`
- `km attach my-container -s my-server`

### Terminals

All terminal commands share the same disconnect shortcut: press **Alt+Q** to end the session.
The session itself stays running and will keep the history if you connect again, or connect from a
different device.

#### SSH / Connect

The `km ssh` command (alias for `km connect`) opens an interactive shell on a server managed by Komodo Periphery. Analogous to `ssh`.

```
km ssh <server> [command] [options]
km connect <server> [command] [options]
```

| Argument | Description |
|---|---|
| `server` | Server name (required) |
| `command` | Shell command to start, e.g. `bash` (optional, defaults to Periphery default) |
| `-n`, `--name` | Terminal session name (default: `ssh`) |
| `-r`, `--recreate` | Force a fresh terminal, replacing any existing session with the same name |

#### Exec

The `km exec` command opens an interactive shell inside a running container. Analogous to `docker exec`.

```
km exec <container> <shell> [options]
```

| Argument | Description |
|---|---|
| `container` | Container name (required) |
| `shell` | Shell to use, e.g. `bash` or `sh` (required) |
| `-s`, `--server` | Server name — required if multiple servers have a container with the same name |
| `-r`, `--recreate` | Force a fresh terminal, replacing any existing session |

#### Attach

The `km attach` command attaches to a running container's main process stdio. Analogous to `docker attach`.

```
km attach <container> [options]
```

| Argument | Description |
|---|---|
| `container` | Container name (required) |
| `-s`, `--server` | Server name — required if multiple servers have a container with the same name |
| `-r`, `--recreate` | Force a fresh terminal, replacing any existing session |

### Install

Expand Down Expand Up @@ -53,7 +109,7 @@ brew tap moghtech/komodo && \

You can alias a docker run command:
```bash
alias km='docker run --rm -v $HOME/.config/komodo:/config ghcr.io/moghtech/komodo-cli km'
alias km='docker run --rm -v $HOME/.config/komodo:/config ghcr.io/moghtech/komodo-cli:2 km'
km config
```

Expand Down
8 changes: 4 additions & 4 deletions docsite/docs/releases/v2.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Komodo v2 is a major release with significant architectural changes and new feat
- **PKI authentication**: Core and Periphery now authenticate with auto-generated key pairs and automatic rotation. Passkeys are deprecated.
- **Onboarding keys**: streamlined server onboarding with reusable keys.
- **Improved terminals**: Terminals dashboard, `km ssh`, and improved Action scripting.
- **Improved auto updates**: Uses a better system to handle auto updates based on image digest.
- **New UI**: Improved look with higher contrast and better UI primitives.
- **Passkey / TOTP 2FA**: Built in two factor authentication for username / password login.
- **Multi-login Linking**: Users can now link multiple login providers (Local, OIDC, Github, etc) to their account.
Expand All @@ -22,7 +23,8 @@ It is largely backward compatible with Komodo v1 configuration, and users can up

:::note
Starting with v2, Komodo will not publish images with the `latest` tag in favor of Semver (`2`, `2.0`, `2.0.0`).
This prevents unintented major version upgrades when using auto updaters.
This prevents unintented major version upgrades when using auto updaters. Use `:2` to stay up to date
with all future Komodo v2 releases.
:::

### 1. Upgrade Core and Periphery to v2
Expand Down Expand Up @@ -63,8 +65,6 @@ Systemd Periphery users just need to update their Periphery binary version. The

After getting both Core and Periphery running, everything should already work correctly at this point.



### 2a. Move to public key authentication

If you want to **reverse the agent connection, [skip this step and go to 2b](#2b-reversing-the-agent-connection)**.
Expand Down Expand Up @@ -119,7 +119,7 @@ onboarding_key = "<YOUR_ONBOARDING_KEY>"

Upon connecting, the privileged onboarding key will allow the existing server's expected public key
to be updated, allowing the Periphery agent to connect.
**In general when onboarding _new_ servers, privilidged mode is not needed.**
**In general when onboarding _new_ servers, privileged mode is not needed.**

### 3. Fix any `komodo.execute_terminal` in Actions

Expand Down
10 changes: 10 additions & 0 deletions docsite/docs/terminals.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ You can create multiple named terminal sessions on the same resource. Each sessi

Each terminal maintains a rolling 1 MiB output buffer. When you reconnect to an existing session, the history is replayed so you can see previous output.

## CLI

Terminal sessions can also be accessed from the command line using the [Komodo CLI](./ecosystem/cli.mdx#terminals).

- `km ssh <server>` — open a shell on a server
- `km exec <container> <shell>` — exec into a container
- `km attach <container>` — attach to a container's main process

Press **Alt+Q** to disconnect from any CLI terminal session while the session itself stays running.

## Execute Terminal

The `execute_terminal` API method allows you to run a command on a terminal and stream the output back over HTTP. This is useful for:
Expand Down
8 changes: 6 additions & 2 deletions ui/src/components/hash-compare.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ export default function HashCompare({
<Badge color="accent.9">message</Badge>
<Text c="dimmed">{lastHash}</Text>
</Group>
<Code>{lastMessage || latestMessage}</Code>
<Code maw="calc(100vh - 150px)" style={{ overflow: "auto" }}>
{lastMessage || latestMessage}
</Code>
</Stack>
{outOfDate && (
<Stack gap="xs">
Expand All @@ -65,7 +67,9 @@ export default function HashCompare({
</Badge>
<Text c="dimmed">{latestHash}</Text>
</Group>
<Code>{latestMessage}</Code>
<Code maw="calc(100vh - 150px)" style={{ overflow: "auto" }}>
{latestMessage}
</Code>
</Stack>
)}
</Stack>
Expand Down
7 changes: 3 additions & 4 deletions ui/src/resources/swarm/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ export default function SwarmConfig({
<Group
key={index}
gap="xs"
w={{ base: "85%", lg: 400 }}
w={{ base: "100%", lg: 400 }}
justify="space-between"
wrap="nowrap"
>
<ResourceSelector
type="Server"
Expand Down Expand Up @@ -105,7 +106,7 @@ export default function SwarmConfig({
})
}
leftSection={<ICONS.Add size="1rem" />}
w={{ base: "85%", lg: 400 }}
w={{ base: "100%", lg: 400 }}
>
Add Server
</Button>
Expand All @@ -118,7 +119,6 @@ export default function SwarmConfig({
{
label: "Alerts",
labelHidden: true,
contentHidden: ((update.links ?? config.links)?.length ?? 0) === 0,
fields: {
send_unhealthy_alerts: {
description: "Send alerts when the Swarm is unhealthy",
Expand Down Expand Up @@ -151,7 +151,6 @@ export default function SwarmConfig({
{
label: "Links",
description: "Add quick links in the resource header",
contentHidden: ((update.links ?? config.links)?.length ?? 0) === 0,
fields: {
links: (values, set) => (
<ConfigList
Expand Down
Loading