public private key explained code example
Example 1: create public key from private
chmod 400 ~/.ssh/id_rsa
ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub
Example 2: Generating Public and Private Key
# the directory where the keys are to be stored
# in this case we are using the current file directory
path = Path(__file__).absolute().parent
# initialize the encrypter
encryption = Encryption(path, name=('public_key.pem', 'private1.pem'))
# generates both private and public keys
encryption.generate_keys()