create public and private key code example

Example 1: add public key to server

ssh-copy-id -i ~/.ssh/mykey.pub user@host

Example 2: create public key from private

chmod 400 ~/.ssh/id_rsa
ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub

Example 3: 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()