Skip to main content

sshconf-tddschn

PyPI version

Note: This is a fork of https://github.com/sorend/sshconf. I published my own version because the upstream project is not publishing the latest version to PyPI.

Sshconf is a library for reading and modifying your ssh/config file in a non-intrusive way, meaning your file should look more or less the same after modifications. Idea is to keep it simple, so you can modify it for your needs.

Read more about ssh config files here: Create SSH config file on Linux

Installation and usage

Install through pip is the most easy way. You can install from the Git source directly:

pip install sshconf-tddschn

Below is some example use:

from sshconf import read_ssh_config, empty_ssh_config_file
from os.path import expanduser

c = read_ssh_config(expanduser("~/.ssh/config"))
print("hosts", c.hosts())

# assuming you have a host "svu"
print("svu host", c.host("svu"))  # print the settings
c.set("svu", Hostname="ssh.svu.local", Port=1234)
print("svu host now", c.host("svu"))
c.unset("svu", "port")
print("svu host now", c.host("svu"))

c.add("newsvu", Hostname="ssh-new.svu.local", Port=22, User="stud1234",
                RemoteForward=["localhost:2022 localhost:22", "localhost:2025 localhost:25"])
print("newsvu", c.host("newsvu"))

c.add("oldsvu", before_host="newsvu", Hostname="ssh-old.svu.local", Port=22, User="Stud1234")

c.rename("newsvu", "svu-new")
print("svu-new", c.host("svu-new"))

# overwrite existing file(s)
c.save()

# write all to a new file
c.write(expanduser("~/.ssh/newconfig"))

# creating a new config file.
c2 = empty_ssh_config_file()
c2.add("svu", Hostname="ssh.svu.local", User="teachmca", Port=22)
c2.write("newconfig")

c2.remove("svu")  # remove

A few things to note:

  • save() overwrites the files you read from.
  • write() writes a new config file. If you used Include in the read configuration, output will contain everything in one file.
  • indent for new lines is auto-probed from existing config lines, and defaults to two spaces.

About

sshconf is created at the Department of Computer Science at Sri Venkateswara University, Tirupati, INDIA by a student as part of his projects.

Metadata

Release files for sshconf-tddschn 0.2.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sshconf-tddschn 0.2.9
File Size Uploaded
sshconf_tddschn-0.2.9.tar.gz 80.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sshconf-tddschn 0.2.9
File Interpreter ABI Platform
sshconf_tddschn-0.2.9-py3-none-any.whl Python 3 none any Details

Total release size: 89.2 kB

Release files / sshconf_tddschn-0.2.9.tar.gz

Download URL sshconf_tddschn-0.2.9.tar.gz
Size 80.8 kB
Tags Source
SHA-256 checksum
How to use checksums
73f64b44f181e5ec2f88ba29f34aa34d4a112f77f2424fbb27bae39ebcb9d62b
BLAKE2b-256 checksum
How to use checksums
21457a664b05cb68822d0bec55390e4ae672daf7cd7be53867be3e476720f2cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / sshconf_tddschn-0.2.9-py3-none-any.whl

Download URL sshconf_tddschn-0.2.9-py3-none-any.whl
Size 8.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
46c1f6559092d21e21339671348e8a6eec6f6033f9e5dd373315702c3168bb52
BLAKE2b-256 checksum
How to use checksums
dda2d84a9dee09fbbded60d71706f16745f23de85d4a15ca586f594a6b7bfe9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.2.9 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page