Created
September 20, 2023 01:11
-
-
Save thebluesnevrdie/f1522bf5305d561f42dac25ff398f2e9 to your computer and use it in GitHub Desktop.
Generate ed25515 OpenSSH keys with Python3 cryptography library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
from cryptography.hazmat.primitives.asymmetric import rsa, ed25519 | |
from cryptography.hazmat.primitives import serialization, hashes | |
private_key = ed25519.Ed25519PrivateKey.generate() | |
public_key = private_key.public_key() | |
our_private = private_key.private_bytes( | |
encoding=serialization.Encoding.PEM, | |
format=serialization.PrivateFormat.OpenSSH, | |
encryption_algorithm=serialization.NoEncryption(), | |
) | |
our_public = public_key.public_bytes( | |
encoding=serialization.Encoding.OpenSSH, format=serialization.PublicFormat.OpenSSH | |
) | |
print(our_private.decode("utf-8")) | |
print("-----BEGIN OPENSSH PUBLIC KEY-----") | |
print(our_public.decode("utf-8")) | |
print("-----END OPENSSH PUBLIC KEY-----") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment