mirror of https://github.com/jumpserver/jumpserver
添加登陆方式
parent
19dcf171e6
commit
ba08602e20
18
connect.py
18
connect.py
|
@ -67,6 +67,7 @@ class Tty(object):
|
|||
self.user = user
|
||||
self.role = role
|
||||
self.ssh = None
|
||||
self.remote_ip = ''
|
||||
self.connect_info = None
|
||||
self.login_type = 'ssh'
|
||||
self.vim_flag = False
|
||||
|
@ -192,17 +193,18 @@ class Tty(object):
|
|||
|
||||
if self.login_type == 'ssh': # 如果是ssh连接过来,记录connect.py的pid,web terminal记录为日志的id
|
||||
pid = os.getpid()
|
||||
remote_ip = os.popen("who -m | awk '{ print $5 }'").read().strip('()\n') # 获取远端IP
|
||||
log = Log(user=self.username, host=self.asset_name, remote_ip=remote_ip,
|
||||
log_path=log_file_path, start_time=date_today, pid=pid)
|
||||
self.remote_ip = os.popen("who -m | awk '{ print $5 }'").read().strip('()\n') # 获取远端IP
|
||||
else:
|
||||
remote_ip = 'Web'
|
||||
log = Log(user=self.username, host=self.asset_name, remote_ip=remote_ip,
|
||||
log_path=log_file_path, start_time=date_today, pid=0)
|
||||
log.save()
|
||||
log.pid = log.id
|
||||
pid = 0
|
||||
|
||||
log = Log(user=self.username, host=self.asset_name, remote_ip=self.remote_ip, login_type=self.login_type,
|
||||
log_path=log_file_path, start_time=date_today, pid=pid)
|
||||
|
||||
log.save()
|
||||
if self.login_type == 'web':
|
||||
log.pid = log.id
|
||||
log.save()
|
||||
|
||||
log_file_f.write('Start at %s\n' % datetime.datetime.now())
|
||||
return log_file_f, log_time_f, log
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ class Log(models.Model):
|
|||
user = models.CharField(max_length=20, null=True)
|
||||
host = models.CharField(max_length=20, null=True)
|
||||
remote_ip = models.CharField(max_length=100)
|
||||
login_type = models.CharField(max_length=100)
|
||||
log_path = models.CharField(max_length=100)
|
||||
start_time = models.DateTimeField(null=True)
|
||||
pid = models.IntegerField()
|
||||
|
|
|
@ -267,6 +267,7 @@ class WebTerminalHandler(tornado.websocket.WebSocketHandler):
|
|||
logger.debug('Websocket: request web terminal Host: %s User: %s Role: %s' % (asset.hostname, self.user.username,
|
||||
login_role.name))
|
||||
self.term = WebTty(self.user, asset, login_role)
|
||||
self.term.remote_ip = self.request.remote_ip
|
||||
self.term.get_connection()
|
||||
self.term.channel = self.term.ssh.invoke_shell(term='xterm')
|
||||
WebTerminalHandler.tasks.append(MyThread(target=self.forward_outbound))
|
||||
|
|
|
@ -102,10 +102,11 @@
|
|||
<th class="text-center"> 用户名 </th>
|
||||
<th class="text-center"> 登录主机 </th>
|
||||
<th class="text-center"> 来源IP </th>
|
||||
<th class="text-center"> 登陆方式 </th>
|
||||
{% ifnotequal session_role_id 0 %}
|
||||
<th class="text-center"> 命令统计 </th>
|
||||
<th class="text-center"> 命令 </th>
|
||||
{% endifnotequal %}
|
||||
<th class="text-center"> 回放录像 </th>
|
||||
<th class="text-center"> 录像 </th>
|
||||
<th class="text-center"> 登录时间 </th>
|
||||
<th class="text-center"> 结束时间 </th>
|
||||
|
||||
|
@ -119,8 +120,9 @@
|
|||
<td class="text-center username"> {{ post.user }} </td>
|
||||
<td class="text-center ip"> {{ post.host }} </td>
|
||||
<td class="text-center remote_ip"> {{ post.remote_ip }} </td>
|
||||
<td class="text-center"> {{ post.login_type }} </td>
|
||||
{% ifnotequal session_role_id 0 %}
|
||||
<td class="text-center"><a href="/jlog/history/?id={{ post.id }}" class="log_command"> 命令统计 </a></td>
|
||||
<td class="text-center"><a href="/jlog/history/?id={{ post.id }}" class="log_command"> 统计 </a></td>
|
||||
{% endifnotequal %}
|
||||
<td class="text-center"><a value="/jlog/record/?id={{ post.id }}" class="log_record"> 回放 </a></td>
|
||||
<td class="text-center start_time"> {{ post.start_time|date:"Y-m-d H:i:s"}} </td>
|
||||
|
|
|
@ -79,7 +79,8 @@
|
|||
<th class="text-center"> 用户名 </th>
|
||||
<th class="text-center"> 登录主机 </th>
|
||||
<th class="text-center"> 来源IP </th>
|
||||
<th class="text-center"> 统计命令 </th>
|
||||
<th class="text-center"> 登录方式 </th>
|
||||
<th class="text-center"> 命令 </th>
|
||||
<th class="text-center"> 实时监控 </th>
|
||||
<th class="text-center"> 阻断 </th>
|
||||
<th class="text-center"> 登录时间 </th>
|
||||
|
@ -92,7 +93,8 @@
|
|||
<td id="username" class="text-center"> {{ post.user }} </td>
|
||||
<td id="ip" class="text-center"> {{ post.host }} </td>
|
||||
<td id="remote_ip" class="text-center"> {{ post.remote_ip }} </td>
|
||||
<td class="text-center"><a href="/jlog/history/?id={{ post.id }}" class="log_command"> 命令统计 </a></td>
|
||||
<td class="text-center"> {{ post.login_type }} </td>
|
||||
<td class="text-center"><a href="/jlog/history/?id={{ post.id }}" class="log_command"> 统计 </a></td>
|
||||
<td class="text-center"><a class="monitor" file_path="{{ post.log_path }}"> 监控 </a></td>
|
||||
<td class="text-center"><input type="button" id="cut" class="btn btn-danger btn-xs" name="cut" value="阻断" onclick='cut("{{ post.pid }}", "{{ post.remote_ip }}")' /></td>
|
||||
<td class="text-center" id="start_time"> {{ post.start_time|date:"Y-m-d H:i:s" }} </td>
|
||||
|
|
Loading…
Reference in New Issue