Skip to main content

Parses ssh2 keys and converts to multiple formats.

Project description

ssh2_parse_key

ci documentation pypi version

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

Installation

With pip:

python3.6 -m pip install ssh2_parse_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.

Development on the python version was done by Nigel Metheringham <nigelm@cpan.org>


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.7.2.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

ssh2_parse_key-0.7.2-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ssh2_parse_key-0.7.2.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.8.0 Linux/4.15.0-1077-gcp

File hashes

Hashes for ssh2_parse_key-0.7.2.tar.gz
Algorithm Hash digest
SHA256 07ded72df4f4d5750a05ff226df9fef8198601d50a08d28e6cd4f4064048eb69
MD5 0860f2b3a9f39de4430b695a6baa7767
BLAKE2b-256 c189e4c33d2923ab0c785c80cdf21147dc72769f3e71b4fdacb5aacddc899f67

See more details on using hashes here.

File details

Details for the file ssh2_parse_key-0.7.2-py3-none-any.whl.

File metadata

  • Download URL: ssh2_parse_key-0.7.2-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.8.0 Linux/4.15.0-1077-gcp

File hashes

Hashes for ssh2_parse_key-0.7.2-py3-none-any.whl
Algorithm Hash digest
SHA256 dc6c66c084a92ef9f9485ddc961f2a13528b182a9860e9a07373fae5d9c7959e
MD5 8d4ad619b7e39427875b8eadf8638e93
BLAKE2b-256 2179d0c2b4741f1f437a6feff481c78a4128776a89c9b6e252a64afea205bbb9

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