Skip to main content

Persistent SSH reverse tunnel for SciTeX (NAT traversal)

Project description

SciTeX Tunnel (scitex-tunnel)

SciTeX

Persistent SSH reverse tunnel for NAT traversal

PyPI version Documentation Tests License: AGPL-3.0

Full Documentation · pip install scitex-tunnel


Problem

Machines behind NAT or institutional firewalls cannot receive incoming SSH connections. Researchers running long experiments on lab workstations, HPC nodes, or edge devices need reliable remote access without manual port forwarding or VPN setup. Existing solutions (ngrok, cloudflared) often require external accounts or lack systemd integration for persistent, auto-recovering connections.

Solution

SciTeX Tunnel creates persistent reverse SSH tunnels using autossh and systemd. Each tunnel runs as a managed service that auto-restarts on failure, survives reboots, and requires only a bastion server with SSH access.

Host (behind NAT) --[reverse tunnel]--> Bastion Server <--[SSH]--> Client
Operation What it does
setup Creates a systemd service that maintains a reverse SSH tunnel via autossh
status Queries systemd for tunnel service state
remove Stops, disables, and deletes the systemd service

Table 1. Three operations. Each maps to a CLI command, Python function, and MCP tool.

Installation

Requires autossh on the host machine (sudo apt install autossh).

pip install scitex-tunnel

SciTeX users: pip install scitex already includes tunnel support.

Quick Start

# Set up a persistent reverse tunnel
scitex-tunnel setup -p 2222 -b user@bastion.example.com -s ~/.ssh/id_rsa

# Check tunnel status
scitex-tunnel status

# Remove a tunnel
scitex-tunnel remove -p 2222

Three Interfaces

Python API
import scitex_tunnel

# Set up tunnel
result = scitex_tunnel.setup(2222, "user@bastion.example.com", "~/.ssh/id_rsa")

# Check status
result = scitex_tunnel.status()
result = scitex_tunnel.status(port=2222)

# Remove tunnel
result = scitex_tunnel.remove(2222)

Full API reference

CLI Commands
scitex-tunnel --help-recursive                # Show all commands
scitex-tunnel setup -p 2222 -b user@host -s ~/.ssh/id_rsa
scitex-tunnel status                          # All tunnels
scitex-tunnel status -p 2222                  # Specific port
scitex-tunnel remove -p 2222                  # Remove tunnel
scitex-tunnel list-python-apis                # List Python API
scitex-tunnel mcp list-tools                  # List MCP tools

Full CLI reference

MCP Server — for AI Agents

AI agents can manage tunnels autonomously.

Tool Description
tunnel_setup Set up a persistent SSH reverse tunnel
tunnel_status Check status of SSH reverse tunnels
tunnel_remove Remove a persistent SSH reverse tunnel

Table 2. Three MCP tools. All tools accept JSON parameters and return JSON results.

scitex-tunnel mcp start

Full MCP specification

Part of SciTeX

Tunnel is part of SciTeX. When used inside the SciTeX framework, tunnel management integrates with the orchestrator:

import scitex

# Manage tunnels through the unified interface
result = scitex.tunnel.setup(2222, "user@bastion.example.com", "~/.ssh/id_rsa")
scitex.tunnel.status()

The SciTeX ecosystem follows the Four Freedoms for researchers:

Four Freedoms for Research

  1. The freedom to run your research anywhere — your machine, your terms.
  2. The freedom to study how every step works — from raw data to final manuscript.
  3. The freedom to redistribute your workflows, not just your papers.
  4. The freedom to modify any module and share improvements with the community.

AGPL-3.0 — because research infrastructure deserves the same freedoms as the software it runs on.


SciTeX

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scitex_tunnel-0.1.0.tar.gz (378.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scitex_tunnel-0.1.0-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file scitex_tunnel-0.1.0.tar.gz.

File metadata

  • Download URL: scitex_tunnel-0.1.0.tar.gz
  • Upload date:
  • Size: 378.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for scitex_tunnel-0.1.0.tar.gz
Algorithm Hash digest
SHA256 617d34999e2ca4e8649eab4bba8a508d995f51ce7dee4a274b37defb3d661bfd
MD5 6a4391ba08e8ec40ace66635f4cae5c8
BLAKE2b-256 b9a589fb4ea59911e57eeba09a687c73adf1ffb7c00c82fbd5f0cd9a0a824199

See more details on using hashes here.

File details

Details for the file scitex_tunnel-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: scitex_tunnel-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for scitex_tunnel-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bf6bf01ad492e6cea71381330f8662489d10ebe46199ac0f747ddae6acab5029
MD5 85b39994102b3652520c248f8c4e5532
BLAKE2b-256 533e2b58ee696b36ab645cf7a268e6879c17a6a3be191d762f30cf89d38c32fe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page