mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-10-22 08:19:04 +00:00
1. role push function use password and public key completed
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
import random
|
||||
import os.path
|
||||
|
||||
from Crypto.PublicKey import RSA
|
||||
from paramiko.rsakey import RSAKey
|
||||
from os import chmod, mkdir
|
||||
from uuid import uuid4
|
||||
|
||||
@@ -49,14 +49,17 @@ def gen_keys():
|
||||
key_path_dir = os.path.join(KEY_DIR, key_basename)
|
||||
mkdir(key_path_dir, 0700)
|
||||
|
||||
key = RSA.generate(4096)
|
||||
key = RSAKey.generate(2048)
|
||||
private_key = os.path.join(key_path_dir, 'id_rsa')
|
||||
public_key = os.path.join(key_path_dir, 'id_rsa.pub')
|
||||
with open(private_key, 'w') as content_file:
|
||||
content_file.write(key.exportKey('PEM'))
|
||||
with open(public_key, 'w') as content_file:
|
||||
content_file.write(key.publickey().exportKey('OpenSSH'))
|
||||
key.write_private_key_file(private_key)
|
||||
|
||||
with open(public_key, 'w') as content_file:
|
||||
for data in [key.get_name(),
|
||||
" ",
|
||||
key.get_base64(),
|
||||
" %s@%s" % ("jumpserver", os.uname()[1])]:
|
||||
content_file.write(data)
|
||||
return key_path_dir
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user