Persistent SSH reverse tunnel for SciTeX (NAT traversal)
Project description
SciTeX Tunnel (scitex-tunnel)
Persistent SSH reverse tunnel for NAT traversal
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 scitexalready 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)
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
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
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
- The freedom to run your research anywhere — your machine, your terms.
- The freedom to study how every step works — from raw data to final manuscript.
- The freedom to redistribute your workflows, not just your papers.
- 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.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
617d34999e2ca4e8649eab4bba8a508d995f51ce7dee4a274b37defb3d661bfd
|
|
| MD5 |
6a4391ba08e8ec40ace66635f4cae5c8
|
|
| BLAKE2b-256 |
b9a589fb4ea59911e57eeba09a687c73adf1ffb7c00c82fbd5f0cd9a0a824199
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf6bf01ad492e6cea71381330f8662489d10ebe46199ac0f747ddae6acab5029
|
|
| MD5 |
85b39994102b3652520c248f8c4e5532
|
|
| BLAKE2b-256 |
533e2b58ee696b36ab645cf7a268e6879c17a6a3be191d762f30cf89d38c32fe
|