sshconf


Namesshconf JSON
Version 0.2.7 PyPI version JSON
download
home_pageNone
SummaryLightweight SSH config library.
upload_time2024-06-29 15:05:22
maintainerNone
docs_urlNone
authorNone
requires_python>=3.5
licenseNone
keywords ssh config
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
sshconf
===========

[![PyPI version](https://badge.fury.io/py/sshconf.svg)](https://pypi.org/project/sshconf/)
[![Build Status](https://github.com/sorend/sshconf/actions/workflows/build.yaml/badge.svg)](https://github.com/sorend/sshconf/actions/workflows/build.yaml)
[![codecov](https://codecov.io/gh/sorend/sshconf/branch/master/graph/badge.svg)](https://codecov.io/gh/sorend/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](https://www.cyberciti.biz/faq/create-ssh-config-file-on-linux-unix/)


Installation and usage
---------------------------

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

```bash
pip install sshconf
```

Below is some example use:

```python
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.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "sshconf",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.5",
    "maintainer_email": null,
    "keywords": "ssh, config",
    "author": null,
    "author_email": "S\u00f8ren A D <sorend@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/b7/8d/6fbc3764da5e883484bf71ae7bb5d07a03f62f4c1d60f5951708584623e0/sshconf-0.2.7.tar.gz",
    "platform": null,
    "description": "\nsshconf\n===========\n\n[![PyPI version](https://badge.fury.io/py/sshconf.svg)](https://pypi.org/project/sshconf/)\n[![Build Status](https://github.com/sorend/sshconf/actions/workflows/build.yaml/badge.svg)](https://github.com/sorend/sshconf/actions/workflows/build.yaml)\n[![codecov](https://codecov.io/gh/sorend/sshconf/branch/master/graph/badge.svg)](https://codecov.io/gh/sorend/sshconf)\n\n\nSshconf is a library for reading and modifying your ssh/config file in a non-intrusive way, meaning\nyour file should look more or less the same after modifications. Idea is to keep it simple,\nso you can modify it for your needs.\n\nRead more about ssh config files here: [Create SSH config file on Linux](https://www.cyberciti.biz/faq/create-ssh-config-file-on-linux-unix/)\n\n\nInstallation and usage\n---------------------------\n\nInstall through pip is the most easy way. You can install from the Git source directly:\n\n```bash\npip install sshconf\n```\n\nBelow is some example use:\n\n```python\nfrom sshconf import read_ssh_config, empty_ssh_config_file\nfrom os.path import expanduser\n\nc = read_ssh_config(expanduser(\"~/.ssh/config\"))\nprint(\"hosts\", c.hosts())\n\n# assuming you have a host \"svu\"\nprint(\"svu host\", c.host(\"svu\"))  # print the settings\nc.set(\"svu\", Hostname=\"ssh.svu.local\", Port=1234)\nprint(\"svu host now\", c.host(\"svu\"))\nc.unset(\"svu\", \"port\")\nprint(\"svu host now\", c.host(\"svu\"))\n\nc.add(\"newsvu\", Hostname=\"ssh-new.svu.local\", Port=22, User=\"stud1234\",\n                RemoteForward=[\"localhost:2022 localhost:22\", \"localhost:2025 localhost:25\"])\nprint(\"newsvu\", c.host(\"newsvu\"))\n\nc.add(\"oldsvu\", before_host=\"newsvu\", Hostname=\"ssh-old.svu.local\", Port=22, User=\"Stud1234\")\n\nc.rename(\"newsvu\", \"svu-new\")\nprint(\"svu-new\", c.host(\"svu-new\"))\n\n# overwrite existing file(s)\nc.save()\n\n# write all to a new file\nc.write(expanduser(\"~/.ssh/newconfig\"))\n\n# creating a new config file.\nc2 = empty_ssh_config_file()\nc2.add(\"svu\", Hostname=\"ssh.svu.local\", User=\"teachmca\", Port=22)\nc2.write(\"newconfig\")\n\nc2.remove(\"svu\")  # remove\n```\n\nA few things to note:\n- `save()` overwrites the files you read from.\n- `write()` writes a new config file. If you used `Include` in the read configuration, output will contain everything in one file.\n- indent for new lines is auto-probed from existing config lines, and defaults to two spaces.\n\n\nAbout\n-----\n\nsshconf is created at the Department of Computer Science at Sri Venkateswara University, Tirupati, INDIA by a student as part of his projects.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Lightweight SSH config library.",
    "version": "0.2.7",
    "project_urls": {
        "homepage": "https://github.com/sorend/sshconf"
    },
    "split_keywords": [
        "ssh",
        " config"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "290d1b6203af0c2c6fe2b161bdca63e751e2324255f4edb3da2f684bffe2b583",
                "md5": "e52e274ed34935574b61b41cfedb4273",
                "sha256": "17fb88c26bdb8e81eb9c1450ff4c0ae1679ea4ee93d2cc1f731034d8c44622f6"
            },
            "downloads": -1,
            "filename": "sshconf-0.2.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e52e274ed34935574b61b41cfedb4273",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.5",
            "size": 6974,
            "upload_time": "2024-06-29T15:05:20",
            "upload_time_iso_8601": "2024-06-29T15:05:20.607148Z",
            "url": "https://files.pythonhosted.org/packages/29/0d/1b6203af0c2c6fe2b161bdca63e751e2324255f4edb3da2f684bffe2b583/sshconf-0.2.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "b78d6fbc3764da5e883484bf71ae7bb5d07a03f62f4c1d60f5951708584623e0",
                "md5": "6f85cc3daa1b529fa51d6ef05078b22d",
                "sha256": "b8bb3d74ba096696a96d8743b8a9188150462e8188386c995f69af3c104c0fa0"
            },
            "downloads": -1,
            "filename": "sshconf-0.2.7.tar.gz",
            "has_sig": false,
            "md5_digest": "6f85cc3daa1b529fa51d6ef05078b22d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.5",
            "size": 11708,
            "upload_time": "2024-06-29T15:05:22",
            "upload_time_iso_8601": "2024-06-29T15:05:22.101729Z",
            "url": "https://files.pythonhosted.org/packages/b7/8d/6fbc3764da5e883484bf71ae7bb5d07a03f62f4c1d60f5951708584623e0/sshconf-0.2.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-29 15:05:22",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sorend",
    "github_project": "sshconf",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "sshconf"
}
        
Elapsed time: 0.28347s