|
|
@ -15,13 +15,10 @@ import getpass
|
|
|
|
from django.core.exceptions import ObjectDoesNotExist
|
|
|
|
from django.core.exceptions import ObjectDoesNotExist
|
|
|
|
from Crypto.Cipher import AES
|
|
|
|
from Crypto.Cipher import AES
|
|
|
|
from binascii import b2a_hex, a2b_hex
|
|
|
|
from binascii import b2a_hex, a2b_hex
|
|
|
|
import re
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
os.environ['DJANGO_SETTINGS_MODULE'] = 'jumpserver.settings'
|
|
|
|
os.environ['DJANGO_SETTINGS_MODULE'] = 'jumpserver.settings'
|
|
|
|
django.setup()
|
|
|
|
django.setup()
|
|
|
|
|
|
|
|
from juser.models import User
|
|
|
|
from juser.models import User, Group
|
|
|
|
from jasset.models import Asset
|
|
|
|
from jasset.models import Asset, IDC
|
|
|
|
|
|
|
|
from jpermission.models import Permission
|
|
|
|
from jpermission.models import Permission
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
@ -109,6 +106,7 @@ def posix_shell(chan, user, host):
|
|
|
|
if not os.path.isdir(today_connect_log_dir):
|
|
|
|
if not os.path.isdir(today_connect_log_dir):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
os.makedirs(today_connect_log_dir)
|
|
|
|
os.makedirs(today_connect_log_dir)
|
|
|
|
|
|
|
|
os.chmod(today_connect_log_dir, 0777)
|
|
|
|
except OSError:
|
|
|
|
except OSError:
|
|
|
|
alert_print('Create %s failed, Please modify %s permission.' % (today_connect_log_dir, connect_log_dir))
|
|
|
|
alert_print('Create %s failed, Please modify %s permission.' % (today_connect_log_dir, connect_log_dir))
|
|
|
|
|
|
|
|
|
|
|
@ -258,7 +256,6 @@ def connect(username, password, host, port):
|
|
|
|
# Set PS1 and msg it
|
|
|
|
# Set PS1 and msg it
|
|
|
|
channel.send(ps1)
|
|
|
|
channel.send(ps1)
|
|
|
|
channel.send(login_msg)
|
|
|
|
channel.send(login_msg)
|
|
|
|
print channel.get_name()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Make ssh interactive tunnel
|
|
|
|
# Make ssh interactive tunnel
|
|
|
|
posix_shell(channel, username, host)
|
|
|
|
posix_shell(channel, username, host)
|
|
|
|