Skip to content

Commit 888e8ec

Browse files
authored
Merge pull request HarshCasper#308 from tejan-singh/master
Generate Public Keys HarshCasper#276
2 parents 7ca80a9 + f93a140 commit 888e8ec

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

Python/RSA_Key_Generation/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Generate Public Keys
2+
## This script is used to create a private/public keypair for SSH-authentication for password-less connecting to a remote server.
3+
4+
+ On running this script, will create two files with (.pem) format which contains public and private key.
5+
+ Defined length of keys are 2048 bits *(recommended size)* which determines the strength of keys.
6+
7+
## To run the script:
8+
1. Install the dependencies by running following command in terminal.
9+
+ pip install pycryptodome
10+
2. Run the script.
11+
+ python rsa_key_generation.py
12+
13+
In case, if you want to know more, Read complete documentation [here](https://pycryptodome.readthedocs.io/en/latest/src/public_key/rsa.html)
14+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from Crypto.PublicKey import RSA
2+
key = RSA.generate(2048)
3+
f = open("private_key.pem", "wb")
4+
f.write(key.exportKey('PEM'))
5+
f.close()
6+
7+
public_key = key.publickey()
8+
f = open("public_key.pem", "wb")
9+
f.write(public_key.exportKey('OpenSSH'))
10+
f.close()

0 commit comments

Comments
 (0)