ar08 commited on
Commit
408c595
1 Parent(s): debd19e

Create gen.py

Browse files
Files changed (1) hide show
  1. gen.py +20 -0
gen.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import paramiko
2
+
3
+ # Define key file names
4
+ private_key_file = 'test_rsa.key'
5
+ public_key_file = 'test_rsa.key.pub'
6
+
7
+ # Generate RSA key pair
8
+ key = paramiko.RSAKey.generate(bits=2048)
9
+
10
+ # Save private key
11
+ with open(private_key_file, 'wb') as f:
12
+ key.write_private_key_file(private_key_file)
13
+
14
+ # Save public key
15
+ with open(public_key_file, 'wb') as f:
16
+ f.write(key.get_base64())
17
+
18
+ print(f'RSA key pair generated and saved:')
19
+ print(f'Private key: {private_key_file}')
20
+ print(f'Public key: {public_key_file}')