Skip to content

Triage Linux SSH and Sudo Activity

Admin
October 5, 2026
9 min read
Intermediate
💻 Target OS: Ubuntu 24.04+ / Debian 12+

Before you begin

  • Applies to:Read-only SSH and sudo log triage on Linux systems using the systemd journal.
  • Where to start:Open a shell on the affected host. Check the journal first and use the distribution's authentication log if it is configured.
  • What you need:Have authorized log access, the incident time window, and the user or host involved.
Guide tools
Guide tools
0/0 Steps (0%)

SSH and sudo records provide useful context about remote access and privilege use. Review them together: an SSH authentication event identifies an access attempt or session, while sudo records can show a later command run with elevated privileges.

This walkthrough uses the systemd journal and read-only commands. Distribution logging differs: Debian and Ubuntu commonly write authentication messages to /var/log/auth.log; RHEL-family systems commonly use /var/log/secure when a syslog service is configured. Journal retention and collection policy determine which records are available.

Ubuntu GNOME Terminal showing bounded journalctl queries and SSH authentication and sudo records in UTC

Journal review: Compare SSH authentication and sudo records using their UTC timestamps, account, source, and command.


01

Record the System and Its Time Configuration

Scope

Record the case ID, host name, affected account, and time range. Compare the host’s clock and time zone with the alerting platform, then use UTC when building the shared timeline. Start with a short window around the alert; widen it only when the evidence calls for it.

Terminal window
hostnamectl --static
timedatectl status
sudo journalctl --list-boots
❯ Illustrative Output (Results Vary)
app-17
Local time: Mon 2026-10-05 09:20:00 CEST
Universal time: Mon 2026-10-05 07:20:00 UTC
Time zone: Europe/Zagreb (CEST, +0200)
Use journalctl --utc in the following queries to compare entries
with other systems on a consistent time basis.

02

Read the Relevant Journal Entries

Log Review

Query SSH daemon and sudo records separately so each result is easy to review. The _COMM match filters on the process name. Use the case’s actual start and end times instead of the example 24-hour interval when investigating a real alert.

Terminal window
sudo journalctl --since '24 hours ago' --until now --utc \
--no-pager -o short-iso-precise _COMM=sshd
sudo journalctl --since '24 hours ago' --until now --utc \
--no-pager -o short-iso-precise _COMM=sudo
❯ Illustrative Output (Results Vary)
2026-10-05T07:22:18.412345Z app-17 sshd[2481]: Failed password for ...
2026-10-05T07:23:04.512345Z app-17 sshd[2510]: Accepted publickey for ...
2026-10-05T07:25:11.612345Z app-17 sudo[2634]: user : TTY=pts/1 ; COMMAND=...

03

Separate Attempts, Sessions, and Elevated Commands

Analysis

For SSH, note whether authentication succeeded, the account, source address, authentication method, and any session open or close messages. For sudo, record the invoking account, target user, terminal, working directory, and command when logged. A failed attempt is not a successful session, and a sudo command is not suspicious solely because it is privileged.

SSH fields to capture:
- Timestamp in UTC
- Success or failure and authentication method
- Account and source address
- Session opened / closed when recorded
- Host and SSH service log source
Sudo fields to capture:
- Invoking account and target user
- TTY, working directory, and command
- Timestamp, host, and source log record
- Whether the command matches an approved task
❯ Illustrative Output (Results Vary)
Example finding:
An accepted public-key login for ops-user came from a new source
address. A sudo command followed two minutes later; owner and
maintenance authorization are not yet confirmed.

04

Check Nearby Sessions and Approved Work

Correlation

Compare the same time window with the change calendar, access gateway, identity provider, endpoint telemetry, and the system’s expected role. A source address may identify a VPN, jump host, NAT gateway, or scanner rather than a person’s workstation. Check the account owner and key-management record before calling a public-key login unauthorized.

Terminal window
last -Fai | head -n 30
sudo lastb -Fai | head -n 30
❯ Illustrative Output (Results Vary)
last reads recorded login sessions when the system maintains them.
lastb reads failed-login records when the system maintains them.
These files may be absent, rotated, incomplete, or outside retention.

05

Check the Distribution's Other Authentication Log

Collection Check

If the journal query is empty, confirm the service name, time window, journal access, and retention first. Some systems forward authentication messages to traditional log files instead of, or in addition to, the journal. Read only the path used by the host’s logging configuration; do not assume that every distribution has both files.

Terminal window
# Debian / Ubuntu, when configured:
sudo grep -E 'sshd|sudo' /var/log/auth.log | tail -n 500
# RHEL / Fedora family, when configured:
sudo grep -E 'sshd|sudo' /var/log/secure | tail -n 500
❯ Illustrative Output (Results Vary)
No matching file or no entries is a collection / retention question
to investigate; it is not proof that no authentication occurred.
Use the timestamps to keep only the case interval. If the interval
spans log rotation, identify and review the relevant rotated files too.

Comments