scitex_ssh
SciTeX SSH - SSH primitives (exec/copy/attach) and gated reverse tunnels.
- exception scitex_ssh.PolicyError[source]
Bases:
RuntimeErrorRaised when an action is denied by the allowlist.
- class scitex_ssh.SSHResult(returncode, stdout, stderr)[source]
Bases:
object- __init__(returncode, stdout, stderr)
- scitex_ssh.attach(host, command=None, *, ssh_opts=())[source]
Interactive ssh -t. Replaces current process via os.execvp; returns rc only on failure-to-launch.
- Return type:
- scitex_ssh.copy_from(host, src, dest, *, recursive=False, ssh_opts=(), runner=None)[source]
scp host:src to local dest.
- Return type:
- scitex_ssh.copy_to(host, src, dest, *, recursive=False, ssh_opts=(), runner=None)[source]
scp local src to host:dest. ssh_opts forwarded via -o.
- Return type:
- scitex_ssh.exec_remote(host, command, *, ssh_opts=(), check=False, timeout=None, runner=None)[source]
Run a command on host via ssh.
ssh_opts is a list of raw ssh flags (e.g. [‘-A’, ‘-o’, ‘StrictHostKeyChecking=no’]) passed through verbatim. Users opt into agent forwarding by passing ‘-A’ themselves.
- Parameters:
runner (callable, optional) – Subprocess invoker matching
subprocess.run’s signature. Defaults tosubprocess.run. Pass a hand-rolled fake from tests to observe and stub the call without mocks.- Return type:
- scitex_ssh.setup(port, bastion_server=None, secret_key_path=None, *, host=None, runner=None, scripts_dir=None)[source]
Set up a persistent SSH reverse tunnel.
- Parameters:
port (int) – The remote port to forward (e.g. 2222).
bastion_server (str, optional) – The bastion/relay server hostname or IP. Falls back to SCITEX_SSH_BASTION_SERVER env var.
secret_key_path (str, optional) – Path to the SSH private key for authentication. Falls back to SCITEX_SSH_SECRET_KEY_PATH env var.
- Returns:
Result with ‘success’, ‘stdout’, ‘stderr’ keys.
- Return type:
- Raises:
ValueError – If bastion_server or secret_key_path is not provided and the corresponding environment variable is not set.
- scitex_ssh.remove(port, *, host=None, runner=None, scripts_dir=None)[source]
Remove a persistent SSH reverse tunnel.