brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: sudoreplay plays back sudo sessions recorded with log_output, a security review tool

Security
~/tips/tip-security-sudo-log-output-sudoreplay

sudo visudo -f /etc/sudoers.d/iolog

Records the terminal output of sudo sessions so you can replay them later.

The auth log tells you that someone ran sudo -i. It doesn’t tell you what they did inside that shell. With I/O logging, sudo records the session, and sudoreplay plays it back like a video.

Add a drop-in with visudo, so a typo can’t lock you out:

sudo visudo -f /etc/sudoers.d/iolog
Defaults log_output

From now on every sudo command runs in a pseudo terminal and its output is saved under /var/log/sudo-io. List and replay the sessions like this:

sudo sudoreplay -l
sudo sudoreplay -l user alice
sudo sudoreplay 00000A

Each session gets a six character ID. Replaying shows the output with the original timing, and you can speed it up while it plays.

There is also log_input, which records what was typed. I’d leave that off, because typed input includes passwords for databases or other tools, and then your log folder holds secrets.

Mind the disk. A sudo session that tails a busy log or runs a big build produces a lot of output, so keep an eye on the size of /var/log/sudo-io. And this is not tamper proof: a user who becomes root can delete the logs. Ship them to another machine if that matters to you.

Further reading: sudoers manual (log_output), sudoreplay manual

More Security tips tcpdump -nn -r capture.pcap port 53 mkcert -install Strict-Transport-Security: max-age=0 Referrer-Policy: strict-origin-when-cross-origin wp super-admin list All Security tips (79) All topics

Link