Fixes in ssh paramiko
This commit is contained in:
parent
6cd4598708
commit
7c4895e32c
4 changed files with 69 additions and 40 deletions
|
|
@ -17,6 +17,9 @@ from modules.pastafari2.libraries.task import Task as SSHTask
|
|||
from modules.pastafari2.models.tasks import Task, LogTask
|
||||
from modules.pastafari2.libraries.configtask import config_task
|
||||
from modules.pastafari2.models.pastafari2 import ServerGroup, ServerDbTask, UpdateServerScripts
|
||||
from paramecio2.libraries.config_admin import config_admin
|
||||
from modules.pastafari2.settings.config_admin import pastafari_admin_i18n, pastafari_admin_i18n, pastafari_settings_i18n, pastafari_servers_i18n, pastafari_groups_i18n, pastafari_tasks_log_i18n, num_element_admin
|
||||
|
||||
from pathlib import Path
|
||||
import paramiko
|
||||
import socket
|
||||
|
|
@ -26,8 +29,8 @@ from collections import OrderedDict
|
|||
from importlib import import_module, reload
|
||||
from modules.pastafari2.libraries.progress import load_progress
|
||||
from modules.pastafari2.libraries.load_task import load_db_in_task
|
||||
from importlib import import_module
|
||||
from subprocess import call
|
||||
from settings import config
|
||||
|
||||
try:
|
||||
import ujson as json
|
||||
|
|
@ -48,6 +51,9 @@ t.env.directories.insert(1, os.path.dirname(__file__).replace('/admin', '')+'/te
|
|||
|
||||
system_path='./ssh/'
|
||||
|
||||
if hasattr(config, 'pastafari_system_path'):
|
||||
system_path=config.pastafari_system_path
|
||||
|
||||
base_path='modules/pastafari2/tasks'
|
||||
|
||||
if hasattr(config, 'pastafari_base_path'):
|
||||
|
|
@ -150,36 +156,37 @@ def pastafari2_edit_global_ssh_keys():
|
|||
|
||||
error=1
|
||||
|
||||
# -C "your_email@example.com" -f $HOME/.ssh/id_rsa
|
||||
if not os.path.isfile(system_path+'id_rsa'):
|
||||
|
||||
arr_type={'dsa': 'ssh-keygen -t dsa', 'ecdsa': 'ssh-keygen -t ecdsa -b 521', 'ed25519': 'ssh-keygen -t ed25519'}
|
||||
|
||||
ssh_key_type=request.args.get('ssh_key_type')
|
||||
|
||||
if ssh_key_type in arr_type:
|
||||
# -C "your_email@example.com" -f $HOME/.ssh/id_rsa
|
||||
|
||||
file_ssh_path='-f {}/id_rsa -q -N ""'.format(system_path)
|
||||
|
||||
if not os.path.isfile(system_path+'id_rsa'):
|
||||
arr_type={'rsa': '-t rsa -b 4096', 'dsa': 'ssh-keygen -t dsa', 'ecdsa': 'ssh-keygen -t ecdsa -b 521', 'ed25519': 'ssh-keygen -t ed25519'}
|
||||
|
||||
ssh_key_type=request.args.get('ssh_key_type')
|
||||
|
||||
if ssh_key_type in arr_type:
|
||||
|
||||
if call(arr_type[ssh_key_type]+' '+file_ssh_path, shell=True) > 0:
|
||||
file_ssh_path='-f {}/id_rsa -q -N ""'.format(system_path)
|
||||
|
||||
if not os.path.isfile(system_path+'id_rsa'):
|
||||
|
||||
error=1
|
||||
else:
|
||||
error=0
|
||||
|
||||
#try:
|
||||
|
||||
#key=paramiko.RSAKey.generate(2048)
|
||||
#key=paramiko.Ed25519Key.generate()
|
||||
#key.write_private_key_file(system_path+'id_rsa')
|
||||
|
||||
#with open(system_path+'id_rsa.pub',"w") as pub_key:
|
||||
# pub_key.write("%s %s" % (key.get_name(), key.get_base64()))
|
||||
|
||||
#except:
|
||||
|
||||
# error=1
|
||||
if call(arr_type[ssh_key_type]+' '+file_ssh_path, shell=True) > 0:
|
||||
|
||||
error=1
|
||||
else:
|
||||
"""
|
||||
config_admin.insert(num_element_admin-1, [pastafari_servers_i18n(), 'modules.pastafari2.admin.dashboard', 'admin_app.pastafari2_dashboard', 'fa-linux'])
|
||||
config_admin.insert(num_element_admin, [pastafari_groups_i18n(), 'modules.pastafari2.admin.groups', 'admin_app.pastafari2_groups', 'fa-object-group'])
|
||||
config_admin.insert(num_element_admin+1, [pastafari_tasks_log_i18n(), 'modules.pastafari2.admin.tasks', 'admin_app.pastafari2_tasks', 'fa-file-text-o'])
|
||||
|
||||
import_module('modules.pastafari2.admin.dashboard')
|
||||
import_module('modules.pastafari2.admin.groups')
|
||||
import_module('modules.pastafari2.admin.tasks')
|
||||
|
||||
print(config_admin)
|
||||
"""
|
||||
|
||||
error=0
|
||||
|
||||
return {'error': error}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue