Metadata-Version: 2.5
Name: ghostcrt
Version: 0.5.0
Summary: Terminal UI for managing multiple SSH sessions with an encrypted password vault
Project-URL: Documentation, https://github.com/ayder/ghostcrt#readme
Project-URL: Repository, https://github.com/ayder/ghostcrt
Project-URL: Issues, https://github.com/ayder/ghostcrt/issues
Author: Sinan Alyuruk
License-Expression: GPL-3.0-only
License-File: LICENSE
Keywords: password-vault,session-manager,ssh,ssh-client,terminal,textual,tui
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: System :: Networking
Classifier: Topic :: System :: Systems Administration
Classifier: Topic :: Terminals
Requires-Python: >=3.12
Requires-Dist: argon2-cffi>=23.1.0
Requires-Dist: cryptography>=50.0.0
Requires-Dist: ghostty-textual==0.1.0
Requires-Dist: sshconf>=0.2.7
Requires-Dist: textual==8.2.8
Provides-Extra: dev
Requires-Dist: packaging>=24.2; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
Requires-Dist: pytest-timeout>=2.4; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: pyyaml>=6.0; extra == 'dev'
Requires-Dist: ruff>=0.8; extra == 'dev'
Description-Content-Type: text/markdown

# ghostcrt

Modern terminal UI for managing multiple SSH sessions with an encrypted
password vault. Inspired by SecureCRT®.

Licensed under [GNU GPLv3](https://github.com/ayder/ghostcrt/blob/main/LICENSE) (GPL-3.0-only).

SecureCRT is a registered trademark of VanDyke Software, Inc. ghostcrt is not affiliated with or
endorsed by VanDyke Software.

## Compact terminal UI

One-row controls and session tabs, arrow-key dropdown menus, clear selection
markers, and a contextual footer keep the interface compact. A grey rule, like
the host sidebar's edge, separates the session tabs from the terminal; when the
tabs have focus, the active tab is outlined in the cursor colour. Narrow terminals
use a host drawer that closes when the SSH terminal gains focus. The host editor
keeps advanced settings collapsed until needed. Colors follow the existing
Textual theme picker (`Ctrl+P`).

Use `Ctrl+T` to return from a session to Hosts, `F10` to focus the menu bar,
and `Ctrl+H` for help. Run `ghostcrt` after installing it below.

## Features (v1)

- Inventory from `~/.ssh/config` **and** `~/.config/ghostcrt/includes/`,
  grouped as a tree (sidebar + fuzzy filter)
- Live interactive SSH sessions in tabs (real `ssh` binary in a PTY)
- Ghostty terminal emulation, scrollback, and input handling via
  [`ghostty-textual`](https://pypi.org/project/ghostty-textual/)
- Encrypted local vault for SSH passwords (Argon2id + AES-256-GCM)
- Password delivery via `sshpass -d` (never in argv / env / disk)
- In-app host config and vault management
- Password profiles: store a password once under a profile id and pick it per
  host from a dropdown
- Textual built-in themes (`Ctrl+P`), applied to both the UI and terminal palette

## System dependencies

- OpenSSH client (`ssh`)
- `sshpass` (required only when connecting with a vault password)

macOS: `brew install hudochenkov/sshpass/sshpass` (or your preferred tap)

## Install

Requires Python 3.12+ on macOS 13+ or glibc Linux 2.27+, on x86_64 or ARM64.
The native terminal library is installed automatically from PyPI; no compilation
is needed.

Install as an isolated command-line tool with uv:

```bash
uv tool install ghostcrt
ghostcrt
```

Or install with pip in a virtual environment:

```bash
python3 -m venv .venv
source .venv/bin/activate
python -m pip install ghostcrt
ghostcrt
```

To upgrade, run `uv tool upgrade ghostcrt` or, in the activated environment,
`python -m pip install --upgrade ghostcrt`.

## Develop

The dependency is pinned to
[`ghostty-textual` 0.1.0 on PyPI](https://pypi.org/project/ghostty-textual/0.1.0/),
which pins `pyghostty==0.1.4`. `uv sync` installs the packages and bundled native
library automatically.

```bash
git clone https://github.com/ayder/ghostcrt.git
cd ghostcrt
uv sync --all-extras
uv run pytest
uv run ghostcrt
```

## CLI

```bash
ghostcrt [--config PATH] [--vault PATH] [--theme NAME] [--debug] [-h] [--version]
```

| Flag | Meaning |
|------|---------|
| `--config` | SSH config file (default `~/.ssh/config`) |
| `--vault` | Vault file path (default `~/.config/ghostcrt/vault.enc`) |
| `--theme` | Textual theme id (persisted if valid) |
| `--debug` | Debug logging to stderr (never logs secrets) |

## Keys

| Key | Action |
|-----|--------|
| `Ctrl+P` | Command palette (themes, etc.) |
| `Ctrl+H` | Show keyboard help |
| `Ctrl+O` | Toggle mouse capture / native terminal selection |
| `Ctrl+T` | From the terminal, show and focus the host list; from Hosts, hide it for a full-width terminal |
| `Ctrl+N`, then `1`–`5` | In the terminal: type that snippet. Elsewhere `Ctrl+N` focuses the host list |
| `/` | Focus host filter (outside the terminal) |
| `F10` | Focus menu bar (outside the terminal) |
| `Esc` (Hosts) | Return to active terminal and close the narrow host drawer |
| `↑↓` / `←→` (menus) | Choose action / switch menu |
| `Ctrl+W` | Close active session |
| `Ctrl+Q` / `Esc` (unlock) | Quit |
| `Shift+PageUp/Down` | Scroll local terminal history |
| Mouse wheel | Scroll local terminal history |
| Right-hand scrollbar | Drag to scroll history; click the track to page |
| Mouse drag | Select text to copy |

Click a tab's **×** to close that session. Exited sessions close immediately;
running or connecting sessions ask for confirmation. `Ctrl+W` and Session → Close
use the same confirmation. `Ctrl+Q` asks before disconnecting any live sessions.

Multiline paste is supported. When the remote application enables bracketed
paste, the text is sent as a single paste block. Otherwise, line breaks are sent
as Enter presses, so pasted shell commands may execute immediately.

Mouse reporting is never forwarded to the remote host. Full-screen programs
(Vim, htop, tmux) may still request it — `set mouse=a` and friends are simply
ignored — so the wheel and text selection always belong to the pane. Use
`Shift+PageUp/Down`, the wheel, or the pane's right-hand scrollbar for scrollback.
On macOS, use `Ctrl+O` to
release mouse capture to the host terminal for native selection, and press it
again to restore ghostcrt mouse handling.

## Groups

A group is a file in `~/.config/ghostcrt/includes/`. The filename is the
group name, so `production.conf` becomes the group `production`.

```
~/.config/ghostcrt/includes/
  production.conf     Host srv1 srv2 srv3
                          User jorn
  staging.conf        Host srv4 srv5 srv6
                          User jornv
```

ghostcrt never writes `~/.ssh/config`. It needs one line at the top:

    Include ~/.config/ghostcrt/includes/*.conf

On first run it offers to add that line for you, backing the file up to
`~/.ssh/config.bak` first. The line must be at the **top** — ssh takes the
first value it finds for each keyword, so an `Include` below a `Host *` block
would be shadowed.

Hosts defined in `~/.ssh/config` stay visible and connectable but are
read-only, marked `[RO]`. Use **Hosts → Copy to group…** to adopt one into a
group, where it becomes editable. Because the include is read first, the copy
wins; the original is marked `⊘ <group>` to show it has been shadowed.

### Clone and delete hosts

**Hosts → Clone selected…** opens an Add host form with the selected host's
settings and vault profile copied. It suggests an unused `-copy` alias; edit it
as needed, save, and choose the destination group. Read-only hosts can also be cloned.

Deleting through **Hosts → Delete selected…** or the editor's **Delete** button
shows the host details and asks for **OK / Cancel** confirmation before removing
the whole host block, including its aliases.

### Advanced host settings

The host editor includes optional fields for `ProxyCommand`, `IdentitiesOnly`,
`UserKnownHostsFile`, `ControlMaster`, `ControlPath`, and `ControlPersist`.
These support configurations such as GCP IAP tunnels without requiring a
manual config-file edit.

The **Forwarding** area accepts one `LocalForward`, `RemoteForward`, or
`DynamicForward` directive per line, including multiple directives of the same
type. Any other host-level SSH option can be entered in **Additional
directives**, one `Directive value` entry per line.

## Vault profiles

A profile is a named password, created with **Vault → Create / update profile…**. Assign
one from the host editor's dropdown or **Vault → Assign profile to selected host…**; `(none)` removes the assignment.

## Snippets

Vault → **Snippets…** stores up to five snippets, each with a short name and a text.
In the terminal, press `Ctrl+N` and then `1`–`5`, or click a snippet's button in the footer, to
type it into the session. `\n` (or a real line break) is typed as Enter, and `\\` types a single
backslash. Snippets are typed as keystrokes, not pasted, so a trailing `\n` submits the line.
They are encrypted in the vault, so they can hold passwords. The text is shown in clear only
while the snippet is open in its editor.

## Security notes

- Master password is never stored. Lost key ⇒ **Reset vault…** and re-enter secrets.
- Vault file mode `0600`; config dir `0700`.
- No recovery mechanism by design.
- Host-key prompts are handled by real `ssh` inside the terminal widget. Vault
  password connections first make a password-free verification connection, so
  you can accept or reject a new host key before `sshpass` starts the login.
- Vault files are format 3 from 0.4.0, which adds snippets; ghostcrt 0.3.2 and earlier cannot
  open them. Older vaults (format 1 or format 2) open normally and are rewritten as format 3 on
  their first change.

## Limitations (v1)

- Reads the top-level `~/.ssh/config` and our own includes directory; other
  `Include` directives are not followed.
- Pattern hosts (`*`, `?`, `!`) are shown as non-connectable settings entries.
- Multi-alias vault entries are per selected alias (no cross-alias fallback).
- Linux + macOS only.

## Tests

```bash
uv run pytest
uv run --no-project python scripts/checks.py         # every CI check, this OS, every Python
uv run --no-project python scripts/checks.py --all   # plus the Ubuntu jobs in Docker
```

CI and the local gate run the same list of checks, kept in `pyproject.toml` under
`[tool.ghostcrt.checks]`: locked sync, Ruff (uncached), tests, a dependency audit on
Ubuntu/Python 3.12, wheel and source builds, `twine check`, and clean wheel/source
installation smoke tests. The runner uses the uv version pinned there, and
`tests/test_ci_drift.py` fails if the workflows stop matching it. `--all` runs the
committed tree (`HEAD`) in an
`ubuntu:24.04` container as a non-root user, so Docker must be running.

The gate prints each test name and the 15 slowest test durations. A 60-second
watchdog covers each test and its teardown, dumping thread stacks and stopping
pytest if it hangs instead of waiting for the CI job limit.

Host-key integration tests use an optional local Docker SSH server and isolated
temporary `known_hosts` files. With `sshpass` installed:

```bash
docker build -t ghostcrt-ssh-test tests/ssh/fixtures
docker run -d --rm --name ghostcrt-ssh-test -p 127.0.0.1:22222:22 ghostcrt-ssh-test
GHOSTCRT_TEST_SSH_PORT=22222 uv run pytest tests/ssh/test_host_key_integration.py
docker stop ghostcrt-ssh-test
```

## Design decisions

`ghostcrt` owns SSH processes, PTYs, host configuration, and the encrypted vault.
`ghostty-textual` owns terminal emulation, rendering, input encoding, and scrollback.
Mouse events stay local so remote applications cannot take over pane selection.

`--config PATH` applies to both the inventory and every SSH connection/reconnect.
It uses OpenSSH's `-F` option, which also bypasses the system-wide SSH config.
The setup check requires a leading, unconditional Include covering all group
files. Existing partial or conditional includes do not satisfy this check.

GitHub CI runs the checks above on Ubuntu 24.04 and macOS 15 with Python 3.12 and 3.14.

## Releases

Update the version in `pyproject.toml`, regenerate `uv.lock`, and record the changes
in `CHANGELOG.md`. Merge the release PR, tag that commit (for this release,
`v0.5.0`), and publish its GitHub Release.

The **Release** workflow checks that the tag matches the package version and runs
the same checks as CI on Linux and macOS with Python 3.12 and 3.14. After all jobs
pass, it builds and smoke-tests the wheel and source distribution, validates PyPI
metadata, and attaches the distributions to the GitHub Release. An isolated job
publishes those same files to PyPI through Trusted Publishing with attestations.
PR and branch builds only validate packages.

Before the first PyPI release:

1. Create a GitHub Actions environment named `pypi` in `ayder/ghostcrt`.
2. Add a pending Trusted Publisher in the owner's
   [PyPI publishing settings](https://pypi.org/manage/account/publishing/) with
   project name `ghostcrt`, owner `ayder`, repository `ghostcrt`, workflow
   `release.yml`, and environment `pypi`. For an existing project, add the
   publisher in that project's publishing settings. No PyPI API token is needed.
3. Merge this PR before publishing the `v0.5.0` GitHub Release.

Retry failed jobs from Actions after fixing any publisher configuration. The
workflow also supports **Actions → Release → Run workflow** on `main` with an
existing published release tag containing this workflow (0.5.0 or later).
It compares existing GitHub assets before reusing them, and skips files already
on PyPI. Published versions cannot be replaced;
use a new version for subsequent releases.
