Skip to main content

sshconf-tddschn

Project description

sshconf-tddschn

PyPI version Build Status codecov

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.

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

sshconf_tddschn-0.2.9.dev0.tar.gz (80.7 kB view details)

Uploaded Source

Built Distribution

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

sshconf_tddschn-0.2.9.dev0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file sshconf_tddschn-0.2.9.dev0.tar.gz.

File metadata

  • Download URL: sshconf_tddschn-0.2.9.dev0.tar.gz
  • Upload date:
  • Size: 80.7 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for sshconf_tddschn-0.2.9.dev0.tar.gz
Algorithm Hash digest
SHA256 2cc93f60e48e1af89b31ea4a326d37cc7a1b5f319a02d1af9a4e894aca66da71
MD5 10a6f5d04779a514613d49674d442d36
BLAKE2b-256 69d4fd8596d57da19cdbbf775abf90b07b411b716561d3a36b0f74e8d65ca466

See more details on using hashes here.

File details

Details for the file sshconf_tddschn-0.2.9.dev0-py3-none-any.whl.

File metadata

  • Download URL: sshconf_tddschn-0.2.9.dev0-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for sshconf_tddschn-0.2.9.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 db83e44fb984dd61621ad17b8e7e16d55edcefa3bc825e1cc0777c370b7ff3a9
MD5 70b881c54a45e57f21f9c2c9bfd19b0e
BLAKE2b-256 92b3ff79157e6db8778d19edaeb9328c998f287ab879c710dc5669864b76870c

See more details on using hashes here.

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