Skip to main content

tunnelrat

tunnelrat is a scripting tool for SSH (think ansible but simpler). It takes a yaml script with a list of commands (connect to host, create forward, run command, wait 15 seconds, etc) and then executes them sequentially. This tool is designed for simple automation scripts and cronjobs where the overhead of ansible or other tools would be too much.

Installation

tunnelrat targets Python 3.11 or newer and uses uv for its environment.

uv sync

Prebuilt standalone executables for Linux and Windows are attached to each GitHub Release, and the package is published to PyPI.

Usage

Run a script:

tunnelrat script --file script.yaml

Or, from a checkout without installing:

uv run python -m tunnelrat script --file script.yaml

Read the built-in documentation:

tunnelrat docs                 # overview of every step type
tunnelrat docs --example       # print a full annotated example script
tunnelrat docs --model connect # documentation for one step type
tunnelrat docs --model all     # documentation for every step type

Script format

A script is made up of a list of steps

steps:
  - connect:
      name: bastion
      host: 10.0.0.10
      port: 22
      os: linux
      user: deploy
      password: deploy_password
      sudo_password: deploy_password
      timeout: 30

  - connect:
      name: database:
      host: 10.0.1.25
      os: linux
      user: dbadmin
      ssh_key_path: ~/.ssh/id_ed25519
      ssh_key_password: key_passphrase

  - comment:
      body: Starting the nightly maintenance run

  - command:
      via: bastion
      script: uptime

  - command:
      via: bastion
      script: systemctl restart nginx
      sudo: true

  - batch:
      via: [bastion, database]
      script: df -h /
      output_dir: ./output/disk_usage
      stdout_output: true

  - forward:
      type: local
      via: bastion
      local_host: 127.0.0.1
      local_port: 15432
      remote_host: 10.0.1.25
      remote_port: 5432

  - wait:
      time: 5

  - block:
      timeout: 3600

tunnelrat docs --example prints a fuller version of this covering every option.

Step types

Step Purpose
connect Open an SSH connection to a host.
forward Open a local or remote port forward through a named host.
command Run one script on one host, optionally under sudo, with optional output capture.
batch Run one script across several hosts in a single step.
wait Pause for a fixed number of seconds.
block Hold the script open (keeping tunnels up) until interrupted, or until a timeout.
comment Print a message in the dashboard.

Each host declares its os (linux or windows), which decides how commands are built and encoded for that target. Commands can select an interpreter with executable; the supported values are bash, sh, pwsh, and python on Linux, and powershell, cmd, and python on Windows.

Development

The project follows a strict lint and format baseline enforced by Ruff.

uv sync
uv run ruff check --fix . && uv run ruff format .
uv run pytest

A docker-compose.yml under tests/ starts a local OpenSSH server for exercising real connections.

Building executables

compile_script.py compiles tunnelrat into a distributable binary with Nuitka:

uv run --extra dev python compile_script.py

The .github/workflows/ pipelines build Linux onefile binaries (glibc and musl, x86_64 and arm64) and Windows standalone installers on every push to main, tag releases from VERSION.txt and CHANGELOG.md, and publish to PyPI.

Release files for tunnelrat 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tunnelrat 0.1.1
File Size Uploaded
tunnelrat-0.1.1.tar.gz 19.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tunnelrat 0.1.1
File Interpreter ABI Platform
tunnelrat-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 41.5 kB

Release files / tunnelrat-0.1.1.tar.gz

Download URL tunnelrat-0.1.1.tar.gz
Size 19.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ebcbf29fd960ad7e6a46eacd212501374724a8f2fa86fd5a9e643fb49fd173cb
BLAKE2b-256 checksum
How to use checksums
f91793ef3cf6501ee2fd2eebc4cadf73f703d1524d9f8d994cf71049554af7b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 19, 2026.

Transparency log

Release files / tunnelrat-0.1.1-py3-none-any.whl

Download URL tunnelrat-0.1.1-py3-none-any.whl
Size 22.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
808e30c0f14fa23360e8571807429fc24d3962e85be062a404cc215164b9742c
BLAKE2b-256 checksum
How to use checksums
179ddbd72e7b2e3fbbf6eadf7772832416ee8b6dacb5b2c6da501e3a01c0e384
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 19, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page