sshconf
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
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 usedIncludein 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 0.2.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sshconf-0.2.7.tar.gz | 11.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sshconf-0.2.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.7 kB
Release files / sshconf-0.2.7.tar.gz
| Download URL | sshconf-0.2.7.tar.gz |
|---|---|
| Size | 11.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b8bb3d74ba096696a96d8743b8a9188150462e8188386c995f69af3c104c0fa0
|
|
BLAKE2b-256 checksum How to use checksums |
b78d6fbc3764da5e883484bf71ae7bb5d07a03f62f4c1d60f5951708584623e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.32.3
|
Release files / sshconf-0.2.7-py3-none-any.whl
| Download URL | sshconf-0.2.7-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
17fb88c26bdb8e81eb9c1450ff4c0ae1679ea4ee93d2cc1f731034d8c44622f6
|
|
BLAKE2b-256 checksum How to use checksums |
290d1b6203af0c2c6fe2b161bdca63e751e2324255f4edb3da2f684bffe2b583
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.32.3
|