October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

How to Log Failed SSH Password Login Attempts on Linux

A distribution-aware guide to finding failed SSH password attempts in journald and syslog, increasing sshd detail safely, distinguishing connection limits from per-user accounting, and investigating failures with PAM and Linux Audit.
Length11 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The quickest way to see failed SSH password attempts is to follow the SSH service journal with sudo journalctl -fu ssh.service. On Debian- and Ubuntu-style systems that also write authentication events to syslog, inspect /var/log/auth.log. If the standard records do not contain enough context, verify the effective sshd settings, temporarily raise LogLevel to VERBOSE, validate the configuration, and reload the daemon. For persistent per-user accounting rather than per-connection messages, use the PAM pam_faillock facility; for independently auditable records, use Linux Audit events.

The exact unit name, file path, message wording, retention period, and PAM layout depend on the distribution and release. Treat the commands below as a decision path: identify the logging backend first, then choose the least expensive level of detail that answers your question.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Where failed SSH password attempts are recorded

OpenSSH sends its messages through the system logging stack. Ubuntu’s Community Help Wiki describes the default as the AUTH syslog facility at INFO level. A host may route that facility into systemd-journald, a traditional syslog text file, or both. The same failed login can therefore appear in a journal query and in a file, while another distribution may expose only one of those views.

Backend Typical way to read it What it gives you Important limitation
systemd-journald sudo journalctl -u ssh.service Structured records, time filtering, and live following The unit may be named sshd.service instead of ssh.service; retention is controlled by the host’s journal policy.
Traditional syslog sudo grep -E 'Failed password|authentication failure|Invalid user' /var/log/auth.log Plain-text authentication history on Debian/Ubuntu-style configurations The file path and rotation policy differ by distribution; a host may route AUTH messages elsewhere.
PAM failure accounting pam_faillock status and its per-user records Persistent account-oriented failure state across connections It depends on PAM stack placement and distribution configuration, and is not the same as sshd’s connection counter.
Linux Audit Audit searches for USER_LOGIN events Independently auditable login results, including res=failed Audit rules, storage, and event availability must already be configured.

Identify the SSH service unit

Ubuntu commonly uses ssh.service, while other distributions use sshd.service. If the first command returns no records, query the alternate unit:

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.
  • sudo journalctl -u ssh.service
  • sudo journalctl -u sshd.service

You can also follow the complete journal temporarily with sudo journalctl -f and attempt one deliberately incorrect password from a separate session. Narrow the result to the SSH unit after you confirm which stream receives the event.

View failures immediately and search older events

Follow the live stream

  1. Open a root-capable terminal on the server.
  2. Run sudo journalctl -fu ssh.service. Replace the unit with sshd.service when that is the installed name.
  3. From a different machine, make one test connection and enter an incorrect password once.
  4. Stop following with Ctrl+C after the expected event appears.

The -f option follows new records and -u limits output to the selected service. This is the most useful view when diagnosing a current incident because it avoids guessing which rotated file contains the event.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Search a time range

For a journal-backed host, use a bounded query such as sudo journalctl -u ssh.service --since '24 hours ago'. Add a pattern filter for the messages you care about:

sudo journalctl -u ssh.service --since '24 hours ago' | grep -E 'Failed password|authentication failure|Invalid user'

To inspect the Debian/Ubuntu-style text log, use:

sudo grep -E 'Failed password|authentication failure|Invalid user' /var/log/auth.log

Authentication messages can be emitted by both sshd and PAM. Searching for all three phrases avoids missing a failure that is represented by a PAM message rather than the familiar sshd wording. Exact capitalization and wording vary with the OpenSSH, PAM, and distribution release.

Check the effective sshd configuration before changing anything

Do not assume that the main configuration file tells you what the daemon is using. Included drop-ins and distribution defaults can override it. Ask the running configuration parser for the effective values:

Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed
sudo sshd -T | grep -E '^(loglevel|syslogfacility|maxauthtries|passwordauthentication|usepam)'

The output is lower-case, one setting per line. These fields answer different questions:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • loglevel: how much diagnostic information sshd emits. The documented default is INFO.
  • syslogfacility: the facility that the syslog layer routes; the usual OpenSSH default is AUTH.
  • maxauthtries: the maximum number of authentication attempts permitted within one connection.
  • passwordauthentication: whether password authentication is enabled at all. A value of no means a password test cannot produce a password-authentication failure.
  • usepam: whether PAM participates in authentication and account processing, which affects messages such as pam_unix(sshd:auth): authentication failure and whether PAM accounting modules can run.

If you use conditional Match blocks, the effective value can depend on the connecting user, address, and host. Test the relevant context rather than editing a setting blindly, and keep an existing administrative session open while making changes.

Increase detail with LogLevel VERBOSE

When normal INFO output does not identify the failed-attempt details you need, Ubuntu’s documentation recommends raising LogLevel to VERBOSE. Make the smallest change possible and return to the prior level after troubleshooting.

Safe change procedure

  1. Back up the active configuration or record the exact line you will change.
  2. Open /etc/ssh/sshd_config or the distribution’s included drop-in that owns the setting.
  3. Set LogLevel VERBOSE. Remove or correct a conflicting later setting if an include overrides the value.
  4. Validate syntax without restarting the service: sudo sshd -t. No output means the syntax check passed; any error must be fixed before reloading.
  5. Reload through the installed service manager, for example sudo systemctl reload ssh.service or sudo systemctl reload sshd.service. Use the unit name that exists on the host.
  6. Follow the journal or inspect the authentication log while reproducing one controlled failure.
  7. After collecting what you need, restore the previous level, run sudo sshd -t again, and reload.

A reload normally applies configuration without terminating established sessions, but keep a second administrative connection available in case the service manager or distribution handles reloads differently. Never use an unvalidated edit as the only path back into a remote server.

Why DEBUG is not a normal setting

DEBUG, DEBUG1, DEBUG2, and DEBUG3 can produce far more output, but the Ubuntu sshd_config(5) manual warns that DEBUG logging violates user privacy and is not recommended. Reserve DEBUG levels for a short, supervised diagnostic window, protect the resulting logs, and restore the normal level immediately afterward.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)

Understand the messages you find

Standard sshd failure

A typical line looks like:

Failed password for USER from ADDRESS port PORT ssh2

USER is the account name presented to sshd, ADDRESS is the source address observed by the server, PORT is the source port, and ssh2 identifies the protocol version. The line means that this password authentication attempt failed; it does not by itself prove that the account exists or that the same person made earlier attempts.

Unknown-account attempts

For a name that is not accepted as a local account, sshd may write Failed password for invalid user USER from ADDRESS ... or a separate Invalid user USER from ADDRESS ... message. Do not rely on one literal sentence when building a parser; OpenSSH and distribution patches can change the wording and ordering.

PAM authentication messages

When PAM handles the authentication path, you may also see a line such as:

pam_unix(sshd:auth): authentication failure

PAM output can add account-oriented context, but it may not repeat every field from the sshd line. Correlate timestamps, user names, process identifiers, and source addresses rather than counting every line as a separate attempt.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Count repeated failures without confusing connections and accounts

For a quick source-address count in the last day, extract the value following from:

Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC
sudo journalctl -u ssh.service --since '24 hours ago' | grep 'Failed password' | grep -oE 'from [^ ]+' | awk '{print $2}' | sort | uniq -c | sort -nr

To group the user strings reported by sshd:

sudo journalctl -u ssh.service --since '24 hours ago' | grep 'Failed password for' | grep -oE 'Failed password for (invalid user )?[^ ]+' | sort | uniq -c | sort -nr

These pipelines are investigative shortcuts, not a security control. They can count repeated retries, include an attacker’s guessed names, and treat one connection’s multiple failures as multiple events. Test the pattern against your own log format before automating a response.

What MaxAuthTries actually limits

The current Ubuntu Jammy sshd_config(5) manual lists a default MaxAuthTries value of 6. It limits authentication attempts per connection, not the number of failures allowed for a user over a day or across separate TCP connections. The same manual states that once failures reach half the configured value, additional failures are logged. A client that reconnects can therefore generate more records even when each individual connection stays below the limit.

Use this setting to control retries within a session, but do not interpret it as a persistent per-user counter. Account history requires PAM failure accounting or another audit mechanism.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Track persistent per-user failures with pam_faillock

pam_faillock adds account-oriented failure tracking through PAM stages. A typical stack can invoke it during preauth, record failures during authfail, and clear or recognize successful authentication during authsucc. The exact lines, ordering, and enabled profile are distribution-specific; changing the order can alter both security behavior and whether a failure is recorded.

Its documented options include:

  • audit: include audit information for failures.
  • silent: suppress user-facing messages in the authentication conversation.
  • no_log_info: suppress informational logging from the module.
  • local_users_only: restrict accounting to local users rather than identities resolved through another source.

Inspect the distribution’s PAM profile before enabling or modifying the module. A system can have sshd messages in the journal while pam_faillock is absent, disabled for SSH, or configured only for selected account classes. Conversely, a faillock record can represent account state that is not obvious from a single sshd line.

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.

When faillock is the right tool

  • Choose sshd/journald or syslog messages when you need the connection’s source address, port, protocol, and event timing.
  • Choose pam_faillock when you need a per-user failure count or account state that persists across connections.
  • Use both when an investigation needs to connect account state to individual network events.

Red Hat guidance describes per-user faillock files. Treat those files as security-sensitive state: protect permissions, include them in the host’s retention and backup decisions only when policy allows, and use the distribution’s supported administration command rather than editing the files by hand.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Use Linux Audit for independently reviewable login results

Audit records provide a separate investigation view from the sshd text emitted to journald or syslog. Red Hat guidance uses USER_LOGIN records and filters for res=failed when examining unsuccessful logins. On a host where audit collection is enabled, an initial search can be:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo ausearch -m USER_LOGIN | grep 'res=failed'

Audit output may contain several records associated with one login attempt, so correlate the event identifier, timestamp, user identifiers, and address before counting. If no USER_LOGIN records exist, that does not prove that SSH had no failures; it may mean the relevant audit rule or service integration is not enabled.

Choose the appropriate logging approach

Question you need answered Preferred source Reason Cost or caveat
What is failing right now? Live journald follow Shows new sshd and PAM events as they arrive Requires the correct unit name and journal access.
Which addresses and names appeared? sshd events in journald or the AUTH log file Usually includes the presented user, source address, and port Message wording differs, so parsers must be tolerant.
How many retries occurred in one connection? sshd records plus MaxAuthTries Matches the connection-scoped limit It is not a day-long or per-user total.
What is the persistent failure state for one account? pam_faillock Maintains PAM-based per-user accounting Configuration and reset behavior vary by distribution.
What result should an auditor review independently? Linux Audit USER_LOGIN Provides audit events with fields such as res=failed Requires audit collection and careful event correlation.
Do you need extra context for a short diagnosis? LogLevel VERBOSE Adds detail recommended by Ubuntu documentation Change, validate, reload, monitor, and then revert.

Troubleshoot missing or incomplete records

The journal command is empty

  • Try both ssh.service and sshd.service.
  • Run sudo journalctl -f while making one controlled test failure to discover which unit emits the event.
  • Check that the SSH daemon is actually managed by systemd and that the journal contains records for the relevant time.
  • Confirm that you are testing password authentication; if passwordauthentication is disabled, a password failure will not be generated.

The file is absent or has no matching lines

  • Confirm the host uses a traditional syslog daemon and that the AUTH facility is routed to the file you are reading.
  • On Debian/Ubuntu-style systems, check /var/log/auth.log; other distributions may use a different secure or authentication destination.
  • Use the journal as the authoritative view when syslog forwarding is disabled or the text file is not configured.
  • Remember that permissions normally require sudo.

Messages do not contain enough detail

  1. Run the effective-configuration command and confirm the current loglevel, syslogfacility, and usepam values.
  2. Temporarily set LogLevel VERBOSE.
  3. Run sudo sshd -t before reloading.
  4. Reload the correct service unit and reproduce one failure.
  5. Return to the former logging level after the investigation.

The count looks too high

Do not add sshd and PAM lines together without correlation; one attempt can produce both. Also separate repeated retries in one connection from new connections, and distinguish an invalid-user guess from a failure for a valid local account. Use timestamps and source addresses to build an event definition that matches your question.

Retention, privacy, and operational safeguards

Neither journald nor syslog has a universal retention period established by OpenSSH. The records available to you depend on local journal limits, syslog rotation, storage capacity, and administrative policy. If you need a historical investigation window, verify retention on the specific host rather than assuming that a month or a year of events exists.

Authentication logs reveal account names, source addresses, timing, and sometimes additional PAM context. Restrict read access, avoid copying them into less-protected locations, and treat temporary VERBOSE or DEBUG output as more sensitive. The Ubuntu manual’s privacy warning is especially relevant on shared systems: DEBUG logging is not a harmless way to obtain more data.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A practical workflow

  1. Identify the backend: try the SSH journal unit, then the distribution’s authentication log.
  2. Confirm the effective settings: inspect loglevel, syslogfacility, maxauthtries, passwordauthentication, and usepam.
  3. Observe one controlled event: follow the live stream and make a single failed password attempt from a separate connection.
  4. Search and correlate: use the phrases Failed password, authentication failure, and Invalid user, then correlate duplicate sshd/PAM lines.
  5. Escalate detail only when necessary: use temporary VERBOSE, validate with sshd -t, reload safely, and revert.
  6. Choose persistent accounting when required: configure and inspect pam_faillock for per-user state, or use Audit USER_LOGIN records for independently reviewable results.
  7. Document local differences: record the unit name, log destination, PAM profile, and retention policy for this host so the next investigation starts with facts rather than assumptions.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.