Skip to main content

Parses ssh2 keys and converts to multiple formats.

Project description

SSH2 Key Parsing

https://img.shields.io/pypi/v/ssh2_parse_key.svg https://img.shields.io/travis/nigelm/ssh2_parse_key.svg Documentation Status

Parses ssh2 public keys in either openssh or RFC4716/Secsh formats and converts to either format.

At this point any attempt to work with private keys will raise an exception.

Features

  • Reads public keys of the following encryption types:-
    • ssh-rsa

    • ssh-dss

    • ecdsa-sha2-nistp256

    • ssh-ed25519

  • Reads either Openssh or RFC4716 format public keys

  • Can read input sets with either or both formats in

  • Can output either format for any key

Usage

To use SSH2 Key Parsing in a project:

from ssh2_parse_key import Ssh2Key

# although you can create the object from internal data the normal method
# would be to use the parse() or parse_file() which return a list of Ssh2Key objects.
# Ssh2Key objects are immutable.
# Load one or more keys in either openssh or RFC4716 from a file
keys = Ssh2Key.parse_file("/path/to/public_key")

# alternatively
data = Path("/path/to/public_key").read_text()
keys = Ssh2Key.parse(data)

# now those keys can be dealt with...
for public_key in keys:
    print(f"This is a {key.type} key")
    print(f"It uses {key.encryption} encryption")
    print(f"comment = {key.comment}")
    print(f"subject = {key.subject}")

    print("RFC4716 format representation")
    print(key.rfc4716)

    print("OpenSSH representation")
    print(key.openssh)

Credits

The package is strongly based on the perl Parse::SSH2::PublicKey module.

The class is built using Michael DeHaan’s ClassForge object system.

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

History

0.1.0 (2020-05-07)

  • First builds - never release on PyPI.

0.2.x (2020-09-25)

  • First release

  • Documentation build

  • CI and release automation

0.3.x (2020-09-27)

  • Fixed up documentation

  • Added a few additional tests

  • This is now reasonably presentable

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

ssh2_parse_key-0.3.0.tar.gz (21.0 kB view details)

Uploaded Source

Built Distribution

ssh2_parse_key-0.3.0-py2.py3-none-any.whl (7.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file ssh2_parse_key-0.3.0.tar.gz.

File metadata

  • Download URL: ssh2_parse_key-0.3.0.tar.gz
  • Upload date:
  • Size: 21.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.0

File hashes

Hashes for ssh2_parse_key-0.3.0.tar.gz
Algorithm Hash digest
SHA256 7c05e116cf2ae6c0b9263cfaa63009c94c07ff434d7f4016db049901a373b064
MD5 180007e49943b24ce1eb70b117dc91e4
BLAKE2b-256 acb9ecf5c55f873ddb60288ce5d618047c691c770a93d84487cf4ff753c21989

See more details on using hashes here.

File details

Details for the file ssh2_parse_key-0.3.0-py2.py3-none-any.whl.

File metadata

  • Download URL: ssh2_parse_key-0.3.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.0

File hashes

Hashes for ssh2_parse_key-0.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 199bfbf06965760c49fdadd8a4b5c10a290910ba8d809b4fc89647bce57000e9
MD5 ca68aef430af89d78eb58ba16487c0d7
BLAKE2b-256 406e723e94ca05a51e8de6f071d8484d5d9dc89b2abaf9f1ea14ece623dd2268

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page