How to Log SSH Key Usage for Shared Accounts

Tracking SSH activity on shared accounts can be challenging. By default, logs only show that a public key was accepted, not which key. With a simple tweak to your sshd configuration, you can log the fingerprint of each key used, making it easy to trace access back to individual users. In this article, we’ll show you how to enable verbose logging, locate the right log files, and map fingerprints to people—giving you a reliable audit trail of SSH access.

Table of Contents

When multiple people share the same Unix account, it can be difficult to track who actually accessed the server and when. This becomes a serious problem if an unapproved change is made—you need to know which key was used to gain access.

Fortunately, OpenSSH can log the public key fingerprint used on login. With a few small changes, you can get clear, timestamped records of which key was used, from where, and when.


Step 1: Enable Verbose Logging in sshd

By default, sshd only logs that a login was accepted. To see the fingerprint of the key used, enable verbose logging:

This instructs sshd to log key fingerprints on successful login.


Step 2: Know Where to Look

Where the logs appear depends on your distro and logging setup:

  • RHEL / CentOS / AlmaLinux / Rocky: /var/log/secure
  • Debian / Ubuntu: /var/log/auth.log
  • Systemd-only setups: logs are in the journal, accessible via journalctl

Examples:


Step 3: Sample Output

Once LogLevel VERBOSE is set, successful logins look like this:

The important parts are:

  • user: the Unix account (e.g. deploy)
  • src: the source IP
  • fp: the SHA256 fingerprint of the key
  • comment: whatever was in the key’s comment field (user@laptop)

Step 4: Map Fingerprints to People

To resolve fingerprints to actual keys in your authorized_keys files:

This generates a lookup table of fingerprints → files → owners → comments.
Now you can match the fingerprint in your logs back to the individual’s key.


Step 5: Bonus—See Who Logged In Recently

Quick way to summarize last 48 hours of key logins:


Step 6: Beyond Key Logging

Tracking the key is a great start, but for full accountability consider:

  • Per-person Unix accounts: best practice, even if they all sudo into a shared role.
  • Meaningful key comments: e.g. lee-laptop-2025.
  • Sudo I/O logging: record commands and outputs.
  • auditd or tlog: log file changes and full TTY sessions.
  • SSH certificates: embed identity directly into a short-lived cert signed by your CA.

Conclusion

If you run shared accounts, you must at least log which key was used.
With LogLevel VERBOSE and a little scripting, you can confidently trace access events back to specific individuals—even if everyone logs into the same account.


✅ With this setup, the next time someone makes an unapproved change, you’ll be able to identify exactly whose key was used to log in.

 

Have a project or a problem?

Talk with a senior engineer for practical recommendations—no obligation.

Leave a comment

Leave a Reply

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

Related Posts

Categories

Get a free consultation from Reliable Penguin

Submit the form—or for immediate service call 866-649-7984.