Parses ssh2 keys and converts to multiple formats.
Project description
ssh2_parse_key
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.
The class is built using Michael DeHaan's ClassForge
object system.
Development on the python version was done by Nigel Metheringham <nigelm@cpan.org>
Project details
Release history Release notifications | RSS feed
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.6.0.tar.gz
(17.4 kB
view details)
Built Distribution
File details
Details for the file ssh2_parse_key-0.6.0.tar.gz
.
File metadata
- Download URL: ssh2_parse_key-0.6.0.tar.gz
- Upload date:
- Size: 17.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.3 CPython/3.8.0 Linux/4.15.0-1077-gcp
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 392b38c8b835a0d18efda8813cfedc8a431f1221797e1446f04d940f0b3f6ed6 |
|
MD5 | 34e1d10a778d0e1fdb1de94b4ec2b8a4 |
|
BLAKE2b-256 | e76aa5a639555ea1d7c2988255476c5f85e94a589e0afee460778fcd37c5b986 |
File details
Details for the file ssh2_parse_key-0.6.0-py3-none-any.whl
.
File metadata
- Download URL: ssh2_parse_key-0.6.0-py3-none-any.whl
- Upload date:
- Size: 17.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.3 CPython/3.8.0 Linux/4.15.0-1077-gcp
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | da410daf61fdb058883bbe2f4a1d6d63d2f1e450cc2262b59d277662f1839521 |
|
MD5 | c1d6b277f5ea16e01656b3ab3bab68a5 |
|
BLAKE2b-256 | f60e53d12ba45b6e533fe4ad808540b3860e247cc87f6fa2abe7e75c3ef49871 |