Skip to main content

Add your description here

Project description

PyAutoSSH

Python 3.9+ License: MIT

A Python tool that automatically reconnects SSH sessions after connection interruptions. Perfect for maintaining persistent connections when using terminal multiplexers like screen or tmux on remote hosts.

Features

  • Automatic reconnection on connection loss
  • Compatible with existing SSH configurations
  • Minimal dependencies

Prerequisites

  • Python 3.9 or newer
  • SSH client (ssh command available in PATH)
  • Configured SSH key-based authentication (recommended)

Installation

# Via pip (or pipx / uvx)
pip install git+https://github.com/chrisdeutsch/pyautossh
pip install pyautossh

# From source
git clone https://github.com/chrisdeutsch/pyautossh
cd pyautossh
pip install .

Usage

Basic Usage

pyautossh <args forwarded to ssh>

# For example
pyautossh -t user@hostname tmux new -A -s session_name

Advanced Configuration

Create an SSH config entry in ~/.ssh/config:

Host hostname-tmux
    User username
    HostName hostname
    RequestTTY yes
    RemoteCommand tmux new-session -A -s base
    ServerAliveInterval 5
    ServerAliveCountMax 1

Then simply connect using:

pyautossh hostname-tmux

The parameters

  • ServerAliveInterval: Time interval (in seconds) for sending keep-alive messages
  • ServerAliveCountMax: Number of keep-alive messages that can be lost before disconnecting
  • RequestTTY: Forces TTY allocation (required for interactive sessions)

can be configured depending on how aggressively you want to reconnect.

Tips

  1. Use key-based authentication
  2. Configure SSH agent for passwordless authentication with passphrase-protected keys
  3. Adjust keep-alive settings based on how aggressive you want to reconnect
  4. Use terminal multiplexers (e.g. tmux or screen) for session persistence

Related Projects

  • autossh - The original AutoSSH by Carson Harding

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

pyautossh-0.2.1.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

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

pyautossh-0.2.1-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file pyautossh-0.2.1.tar.gz.

File metadata

  • Download URL: pyautossh-0.2.1.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for pyautossh-0.2.1.tar.gz
Algorithm Hash digest
SHA256 631bd7451fc5e8cea8d87f024712f4b37b4e9c58fe85b4f0a573537081152ea6
MD5 934fc7cbbf1f8d2daec22c937dcd6971
BLAKE2b-256 8c7e3439f6e1762563a69f813689e25dbcadbcd54520cddd6246952c0d481899

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyautossh-0.2.1.tar.gz:

Publisher: publish.yaml on chrisdeutsch/pyautossh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyautossh-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: pyautossh-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for pyautossh-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dfbf76245481729e6a0dc2ed5eef7a3fe0b4644227abeca165737c3da77636fa
MD5 8006a80fd3a01783b972b859287bf967
BLAKE2b-256 3686b7462cced3231a7b79fea5bae517b30026ca6f8627f051e367b0e2eb5e0b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyautossh-0.2.1-py3-none-any.whl:

Publisher: publish.yaml on chrisdeutsch/pyautossh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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