USER SESSION RECORDING IN COCKPIT Nikolai Kondrashov Software - - PowerPoint PPT Presentation

user session recording in cockpit
SMART_READER_LITE
LIVE PREVIEW

USER SESSION RECORDING IN COCKPIT Nikolai Kondrashov Software - - PowerPoint PPT Presentation

USER SESSION RECORDING IN COCKPIT Nikolai Kondrashov Software Engineer 03.02.2018 INTRODUCTION Nikolai spbnick Kondrashov, a software engineer Working at Red Hat Common Logging team Focusing on the User Session Recording project


slide-1
SLIDE 1

USER SESSION RECORDING IN COCKPIT

Nikolai Kondrashov Software Engineer 03.02.2018

slide-2
SLIDE 2

User Session Recording in Cockpit - Nikolai Kondrashov, Red Hat 2

INTRODUCTION

Nikolai “spbnick” Kondrashov, a software engineer

  • Working at Red Hat Common Logging team
  • Focusing on the User Session Recording project
  • Maintaining FreeRADIUS packages
  • Founder and maintainer of the DIGImend project
  • Flirting with embedded as a hobby
slide-3
SLIDE 3

User Session Recording in Cockpit - Nikolai Kondrashov, Red Hat 3

WHAT ARE WE TRYING TO DO?

User Session Recording Project:

  • Record what users see on and type into a terminal
  • Record the commands they execute and files they access
  • Control centrally what, where and who is recorded
  • Store recordings centrally and securely
  • Allow searching, correlation, and playback of recordings
slide-4
SLIDE 4

User Session Recording in Cockpit - Nikolai Kondrashov, Red Hat 4

WHY ORGANIZATIONS NEED IT?

Government, medical, financial, and others:

  • Required by law
  • Want to find out who broke the servers and how
  • Need to know who stole their data
  • Want to trace user problems
slide-5
SLIDE 5

User Session Recording in Cockpit - Nikolai Kondrashov, Red Hat 5

THERE IS A SUPPLY

A great number of commercial offerings:

  • From application-level proxies on dedicated hardware
  • To user-space processes on the target system
  • Recording keystrokes, display, commands, apps, URLs, etc.
  • Integrated with identity management and access control
  • With central storage, searching, and playback
slide-6
SLIDE 6

User Session Recording in Cockpit - Nikolai Kondrashov, Red Hat 6

BUT NO OPEN SOURCE

All we have is:

  • script(1) plus duct tape

popular, but not security-oriented, needs lots of DIY

  • sudo(8) I/O logging

security-oriented, has searching, but not centralized

  • TTY audit with auditd(8)

security-oriented, can be centralized, but only for input

slide-7
SLIDE 7

User Session Recording in Cockpit - Nikolai Kondrashov, Red Hat 7

OUR APPROACH

  • Use logging infrastructure for delivery

Centralization solved

Easily correlate with other logs

Save on resources and maintenance

  • Record terminal I/O from userspace with tlog

Fast to iterate

Easy for users to try

  • Use audit logs for the rest

Commands executed, files accessed, everything already there

slide-8
SLIDE 8

User Session Recording in Cockpit - Nikolai Kondrashov, Red Hat 8

OUR TARGETS

Long- and short-term

  • Enterprise-ready long-term

Storage in Elasticsearch

Central control with FreeIPA and SSSD

Playback via a Web UI component

Embedded in OpenShift, CloudForms, etc.

  • Cockpit short-term

Storage in Journal

Control via SSSD or manual

Configuration and playback in Cockpit Web UI

slide-9
SLIDE 9

User Session Recording in Cockpit - Nikolai Kondrashov, Red Hat 9

WHAT IS COCKPIT?

A server management WebUI with a new twist:

  • “A Linux session in a browser”

Each login creates an actual user session

  • Not taking over the system

Jump between the WebUI and the command line any time

  • Can manage multiple hosts in one session
  • Releases every other week
  • Extensively tested
slide-10
SLIDE 10

DEMO

slide-11
SLIDE 11

User Session Recording in Cockpit - Nikolai Kondrashov, Red Hat 11

DEMO

In this demo:

  • A recorded user logs in and works on a terminal
  • User’s terminal I/O is recorded to Journal
  • Live recording appears and plays back in Cockpit
slide-12
SLIDE 12

HOW IT WORKS

slide-13
SLIDE 13

User Session Recording in Cockpit - Nikolai Kondrashov, Red Hat 13

RECORDING SETUP

  • Recording process starts as the user’s login shell
  • Executes the actual shell under a PTY
  • Captures everything passing between TTY and PTY
  • Cuts it into pieces on time and size limits
  • Encodes to JSON and logs
slide-14
SLIDE 14

User Session Recording in Cockpit - Nikolai Kondrashov, Red Hat 14

JSON SCHEMA

Optimized for streaming and searching:

  • Stream cut into time- and size-limited

pieces, but can be merged back

  • Input and output stored separately
  • Timing separate, ms precision
  • Window resizes preserved
  • All I/O preserved
  • Invalid UTF-8 stored separately

For every message

{ "ver" : "2.2", "host" : "tlog-client.example.com", "rec" : "c8aa248c81264f5d98d1..." "user" : "user1", "term" : "xterm", "session" : 23, "id" : 1, "pos" : 0, "timing" : "=56x22+98>23", "in_txt" : "", "in_bin" : [ ], "out_txt" : "[user1@tlog-client ~]$ ", "out_bin" : [ ] }

slide-15
SLIDE 15

User Session Recording in Cockpit - Nikolai Kondrashov, Red Hat 15

JOURNAL FORMAT

Exposes key fields

_AUDIT_SESSION=23 _AUDIT_LOGINUID=1000 TLOG_REC=c8aa248c81264f5d98d1... TLOG_USER=user1 _UID=987 TLOG_SESSION=23 TLOG_ID=1 _COMM=tlog-rec-sess _EXE=/usr/bin/tlog-rec-session _TRANSPORT=journal MESSAGE={"ver":"2.2","host":...} SYSLOG_IDENTIFIER=tlog-rec-session ... { "ver" : "2.2",_ "host" : "tlog-client.example.com", "rec" : "c8aa248c81264f5d98d1..." "user" : "user1", "term" : "xterm", "session" : 23, "id" : 1, "pos" : 0, "timing" : "=56x22+98>23", "in_txt" : "", "in_bin" : [ ], "out_txt" : "[user1@tlog-client ~]$ ", "out_bin" : [ ] }

slide-16
SLIDE 16

User Session Recording in Cockpit - Nikolai Kondrashov, Red Hat 16

COCKPIT JOURNAL INTERFACE

Simple but effective

  • Host side runs journalctl --output=json
  • Browser side supplies options and arguments and gets JSON
  • Not very efficient, but simple and reliable
slide-17
SLIDE 17

User Session Recording in Cockpit - Nikolai Kondrashov, Red Hat 17

LISTING RECORDINGS

  • Add a match on the UID of SUID recording process

E.g. _UID=987

  • Add a match on recorded username, if filtering

E.g. TLOG_USER=user1

  • Add --since and --until, if limiting by time
  • Run journalctl --lines=all --follow
  • Read all returned entries
  • Aggregate IDs of unique recordings and their info
slide-18
SLIDE 18

User Session Recording in Cockpit - Nikolai Kondrashov, Red Hat 18

PLAYING RECORDINGS

  • Add a match on the UID of the SUID recording process

E.g. _UID=987

  • Add a match on recording ID

E.g. TLOG_REC=c8aa248c81264f5d98d1...

  • Run journalctl --lines=all --follow
  • Read and decode all returned entries in background
  • Playback as necessary
slide-19
SLIDE 19

CHALLENGES

slide-20
SLIDE 20

User Session Recording in Cockpit - Nikolai Kondrashov, Red Hat 20

GETTING AUDIT LOGS

Herding cats

  • We need audit log to get more data about the session

Session boundaries

Commands executed

Files accessed

  • Journald logs audit events, but it is

Unreliable under load (says auditd team)

Raw, messy data

  • We made a tool to cook audit logs, called aushape

Parses, augments, normalizes

Logs in JSON or XML

slide-21
SLIDE 21

User Session Recording in Cockpit - Nikolai Kondrashov, Red Hat 21

ADDING AUDIT LOGS

Befriending cats

  • Make aushape log data as Journal fields
  • r...
  • Just get on with Journald audit logs
  • still...
  • Journal doesn’t support partial field matches

Searching commands/files is inconvenient

Searching I/O is impossible

slide-22
SLIDE 22

User Session Recording in Cockpit - Nikolai Kondrashov, Red Hat 22

  • Show sessions active at each point in

time, recorded and otherwise

  • Show a list of all sessions
  • Sync log scrolling with playback
  • Support full-screen playback

INTEGRATION WITH LOGS PAGE

New design

slide-23
SLIDE 23

User Session Recording in Cockpit - Nikolai Kondrashov, Red Hat 23

  • Enable/disable recording users by

changing their shells

  • Enable/disable recording particular

users/groups via SSSD

Only available for accounts managed by SSSD

  • See the list of sessions, recorded and
  • therwise, for each user/group

INTEGRATION WITH ACCOUNTS PAGE

New design

slide-24
SLIDE 24

User Session Recording in Cockpit - Nikolai Kondrashov, Red Hat 24

TERMINAL TYPES

  • Not many types today, but quirks still possible
  • Same terminal needed to playback on command line
  • Hard to cleanup after playback on command line
  • Only a subset is supported by Web UI playback
  • Embed a terminal emulator library into recording, long-term

Ensures single terminal type to deal with

Libvterm seems a good fit

slide-25
SLIDE 25

User Session Recording in Cockpit - Nikolai Kondrashov, Red Hat 25

CHARACTER ENCODINGS

  • We need UTF-8 to store and search consistently
  • Not everyone uses UTF-8
  • Converting charset of I/O might lose data
  • We’ll need to keep both original and converted I/O

Original I/O compressed?

Converted I/O sanitized?

slide-26
SLIDE 26

User Session Recording in Cockpit - Nikolai Kondrashov, Red Hat 26

PLAYBACK SEEKING

  • Terminal state accumulates, depends on everything before
  • Seeking requires a known state to build upon
  • At the moment it’s the start state only

Slow for big recordings

  • Web UI player has access to terminal emulator internals

Build and use terminal state snapshots — “key frames”

  • If we embed terminal emulator library into recording

Take and log “key frames” on the fly

slide-27
SLIDE 27

TRY IT!

slide-28
SLIDE 28

User Session Recording in Cockpit - Nikolai Kondrashov, Red Hat

  • Checkout our scribery branch
  • Build and run from source

Read HACKING.md

  • Install tlog
  • Create a user with shell set to /usr/bin/tlog-rec-session
  • Login as that user and do some stuff
  • Checkout “Session Recording” page at http://localhost:9090

28

TRY IT!

https://github.com/Scribery/cockpit/tree/scribery

slide-29
SLIDE 29

THANK YOU

User Session Recording Project http://scribery.github.io/

slide-30
SLIDE 30

THANK YOU

plus.google.com/+RedHat linkedin.com/company/red-hat youtube.com/user/RedHatVideos facebook.com/redhatinc twitter.com/RedHatNews