skillfed

sshconf

Lightweight SSH config library.

sshconf v0.2.7 500.0K downloads/30d#6,323 on PyPI102
Permissive license Active released

What it is and what it does

sshconf is a lightweight library for reading and writing SSH configuration files programmatically. It parses the standard SSH config format and lets you query, add, modify, and remove host entries while preserving the file's original formatting and comments—important because SSH config files are often hand-edited and need to remain readable.

The library provides methods to read an existing config, inspect host settings, update individual hosts or create new ones, rename entries, and write changes back to the file or to a new file. It automatically detects indentation from existing config lines and handles multi-value directives like RemoteForward. Since it has no runtime dependencies and requires only Python 3.5 or later, it integrates easily into automation scripts, configuration management tools, or any application that needs to manage SSH access programmatically.

Use it for:

  • Automate SSH host configuration in deployment or infrastructure-as-code scripts.
  • Build configuration management tools that need to update SSH settings without breaking manual edits.
  • Generate SSH config entries dynamically from a database or API of hosts and credentials.
  • Programmatically manage SSH tunnels, port forwards, or jump-host configurations.
  • Parse and audit existing SSH configs to validate host settings or compliance policies.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

sshconf reads and modifies SSH config files while preserving their formatting and structure, letting you programmatically manage SSH host entries and settings.

Yes. sshconf is a straightforward, actively maintained tool with no dependencies, permissive licensing, and a clear use case. Install it if you need to read or modify SSH config files from Python code; skip it if you only work with SSH configs manually or through shell scripts.

Install

sshconf on PyPI

pip

pip install sshconf

uv

uv add sshconf

poetry

poetry add sshconf

Installing sshconf

Before you install

No runtime dependencies and a pure-Python wheel distribution keep installation friction minimal. The package is actively maintained with a recent commit history.

License in practice

MIT license permits free use, modification, and distribution with minimal restrictions—suitable for most projects.

Quickstart

from sshconf import read_ssh_config
from os.path import expanduser

c = read_ssh_config(expanduser("~/.ssh/config"))
print(c.hosts())
c.set("myhost", Hostname="example.com", Port=22)
c.save()

Verify before relying

  • Whether the library handles all SSH config directives and edge cases reliably in production use.
  • Performance characteristics when working with very large or complex SSH config files.

Package facts

License not declared (permissive)
Python support supports the current Python release (>=3.5)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance actively maintained — 776 days since the last release
Last repo commit
First released
Downloads 500,008/month — #6,323 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: sshconf-0.2.7-py3-none-any.whl

Keywords: ssh, config

License :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Topic :: Software Development :: LibrariesTopic :: Software Development :: Libraries :: Python Modules

Tags

ssh config file parsermodify ssh config programmaticallyssh host management libraryparse ssh configurationssh config reader writer
ssh-configsystem-administration

More Libraries packages