You check your new Linux server’s SSH logs. Someone tried to log in as root. Then admin. Then another username you’ve never created.
The requests came from unfamiliar IP addresses. You didn’t invite those connections, and you have no idea who sent them. Does this mean somebody has broken into your server — or are you seeing something entirely different?
In the first lesson, we explored what changes when a Linux server receives a public IP address. We learned that automated systems can discover services without knowing a domain name.
Now we’re following one of those connections further.
This time, a remote client has reached SSH — the service commonly used to administer Linux servers remotely.
SSH has recorded a series of messages. Some look threatening. Others seem ordinary. The challenge is understanding which messages describe failed access, which describe successful authentication, and which simply tell us that a connection occurred.
Unfamiliar SSH login attempts on a public Linux server often come from automated systems probing reachable SSH services. Messages such as Invalid user or Failed password generally describe rejected authentication attempts, not successful access. An Accepted publickey or Accepted password message deserves closer investigation when you cannot account for the user, source or timing. The safest first step is to read the evidence without changing the server.
- 1. A Strange Message Appears in the SSH Log
- An invalid username is requested
- A password attempt fails
- Another account is attempted
- 2. How Does an Unknown Client Reach SSH?
- 3. Understanding the Most Important SSH Log Messages
- 4. Why Do Bots Try Usernames Like root, admin, or guest?
- Automated credential guessing
- Broad internet scanning
- Misconfigured automation
- Legitimate user error
- 5. Which SSH Events Deserve Your Attention?
- 6. Safe Lab: Read SSH Login Attempts on Your Own Server
- Step 1 — Find your SSH service name
- Step 2 — Read recent SSH journal entries
- Step 3 — Check the SSH syslog identifiers
- Step 4 — Check distribution log files
- Step 5 — Narrow the investigation
- 7. What Does a Successful SSH Login Look Like?
- 8. Can You Find Previous Successful Sessions?
- 9. A Mini Investigation: Three Events, Three Conclusions
- 10. What If You Find an Unknown Successful Login?
- 11. Why You Shouldn’t Immediately Disable SSH
- 12. Common Mistakes When Reading SSH Logs
- Assuming every failure is an attack
- Counting log lines as connections
- Ignoring time and context
- Sharing raw authentication logs
- 13. What You Should Understand Before Securing SSH
- 14. Frequently Asked Questions
- 15. What Comes Next?
- Primary Technical Sources
- A failed SSH login is evidence of an attempt, not proof of a breach.
1. A Strange Message Appears in the SSH Log
Imagine a small VPS running Ubuntu Server. You are its administrator, and you normally connect using an SSH key.
While reviewing the server’s authentication records, you notice these messages:
Oct 24 02:14:06 vps-lab sshd[4201]:
Invalid user guest from 198.51.100.42 port 51218
Oct 24 02:14:08 vps-lab sshd[4201]:
Failed password for invalid user guest
from 198.51.100.42 port 51218 ssh2
Oct 24 02:15:32 vps-lab sshd[4250]:
Failed password for deploy
from 203.0.113.24 port 53992 ssh2
These are constructed teaching examples, not measurements from a live VPS. The addresses are documentation-only IP ranges. Real journal entries typically appear as one line per event, and formatting varies by OpenSSH version.
At first glance, it looks like someone is trying to enter the server.
But let’s separate what these messages actually establish from what we might be tempted to assume.
An invalid username is requested
The client presents the username guest. SSH reports that the username is invalid in this authentication context. This does not mean a login succeeded.
A password attempt fails
The server rejects a password authentication attempt. The client did not authenticate successfully through that attempt.
Another account is attempted
A separate connection attempts password authentication for deploy. The failure message alone doesn’t identify the client as malicious or prove the username belongs to an actual authorized administrator.
Notice what we haven’t seen: evidence that the remote client successfully authenticated.
The presence of a login attempt is not the same thing as a successful login. That difference should guide the entire investigation.
2. How Does an Unknown Client Reach SSH?
SSH usually listens on TCP port 22 unless the administrator has configured another port.
If the port is reachable from the internet, a remote client can establish a network connection and begin communicating with the SSH service.
That client may be a legitimate administrator, an automated inventory system, a monitoring service, a misconfigured script, or an attacker.
We cannot reliably determine which one from the connection itself.
These are simplified conceptual stages. The real SSH protocol also negotiates algorithms, establishes encrypted communication, and performs additional checks.
An automated scanner might disconnect after learning that an SSH service exists. Another client may try to authenticate using a common username. Still another may complete authentication using an authorized key.
The log entries reflect different points in that process.
Importantly, packets dropped by a provider firewall or host firewall may never reach the SSH daemon and therefore may not appear in its authentication logs.
3. Understanding the Most Important SSH Log Messages
You do not need to memorize every OpenSSH message. Start by learning what a few common event types mean — and, equally importantly, what they do not prove.
| Log message | Meaning | Interpretation |
|---|---|---|
Invalid user |
The requested account name is not accepted as valid in that authentication context. | Investigate patterns, but do not treat it as a successful login. |
Failed password |
A password authentication attempt was rejected. | A failed attempt, not proof of a breach. |
Failed publickey |
A presented public key was not accepted for authentication. | Could involve an unauthorized client or a legitimate key mismatch. |
Accepted publickey |
SSH accepted public-key authentication for the indicated account. | Verify the account, source, time, and expected activity. |
Accepted password |
SSH accepted password authentication for the indicated account. | Verify that this matches an authorized login. |
Connection closed |
A connection ended. | Context and authentication stage determine its significance. |
These message strings and their presence can vary with OpenSSH version, logging configuration, authentication methods and distribution packaging.
For example, some systems may log activity under sshd, while others may show messages involving sshd-session.
Never build an entire security conclusion around a single exact text pattern.
4. Why Do Bots Try Usernames Like root, admin, or guest?
Automated clients can submit account names that are common across operating systems, hosting setups and applications.
Some attempt username and password combinations. Others simply record how an authentication service responds.
The server owner may never have created the requested accounts.
Automated credential guessing
Software repeatedly tries possible account credentials against reachable authentication services.
Broad internet scanning
A system discovers SSH endpoints across many addresses and may collect protocol information.
Misconfigured automation
An old script, backup task or deployment service may repeatedly attempt to use invalid credentials.
Legitimate user error
An administrator can produce failed logins by choosing the wrong account, key or password.
This is why a failed login is an observation, not a complete explanation of intent.
Repeated guessing against common account names can indicate automated abuse, but a small number of failures may also come from ordinary operational mistakes.
Correlate usernames, source addresses, timing and other evidence before assigning a cause.
5. Which SSH Events Deserve Your Attention?
There is no universal number of failed attempts that separates harmless background activity from a serious security incident.
One failed attempt could be an ordinary typo. Hundreds may come from an automated guessing campaign. But even a single successful authentication from an unexplained source may deserve investigation.
A remote client reaches the SSH endpoint. This establishes visibility and connectivity, not unauthorized access.
Look for concentration around accounts, sources and time periods. Investigate why the attempts occur and whether defensive controls behave as intended.
Determine whether it belongs to an authorized user, VPN endpoint, automation service or unexpected credential holder.
Unknown successful authentication combined with unexpected accounts, processes, key changes or privileged actions warrants prompt incident investigation.
These are investigation priorities, not a formula that calculates the probability of compromise.
A message containing Accepted establishes successful SSH authentication for that event. It does not, on its own, prove malicious activity or reveal everything the authenticated client did afterward.
6. Safe Lab: Read SSH Login Attempts on Your Own Server
Let’s examine authentication records using read-only Linux commands.
You won’t need to trigger failed logins, change your SSH configuration, disable a firewall or restart any services.
Step 1 — Find your SSH service name
On many Ubuntu and Debian installations, the service is called ssh.service. On many RHEL-family systems, it is sshd.service.
Check which service exists:
systemctl status ssh.service --no-pager
systemctl status sshd.service --no-pager
One command may report that the unit doesn’t exist. That can be normal. Use the appropriate unit name for the remaining steps.
Some installations use socket activation or other arrangements, so service state alone is not a complete measure of SSH reachability.
Step 2 — Read recent SSH journal entries
For Ubuntu or Debian systems using ssh.service:
sudo journalctl -u ssh.service \
--since "24 hours ago" \
--no-pager
For systems using sshd.service:
sudo journalctl -u sshd.service \
--since "24 hours ago" \
--no-pager
The -u flag selects a unit. The time filter limits how much history is displayed.
Depending on how SSH messages are delivered to the journal, a unit-specific query may omit authentication entries. An empty result does not prove there were no connection attempts.
Step 3 — Check the SSH syslog identifiers
If the unit view doesn’t show the authentication messages you expect, try querying common SSH identifiers:
sudo journalctl \
-t sshd \
-t sshd-session \
--since "24 hours ago" \
--no-pager
Repeated -t options select messages using either specified identifier.
Other SSH-related messages may still be logged under different identifiers. Use the journal’s available metadata rather than assuming this command captures everything.
Step 4 — Check distribution log files
Depending on your distribution and logging configuration, authentication messages may also be stored in traditional files.
On systems with /var/log/auth.log:
sudo tail -n 100 /var/log/auth.log
On systems with /var/log/secure:
sudo tail -n 100 /var/log/secure
The files may not exist if the relevant syslog service is not installed, logging is journal-only, or file logging has been configured differently.
These files may contain other authentication-related events, not just SSH.
Step 5 — Narrow the investigation
Once you’ve identified the correct log source, examine the period when the suspicious activity occurred.
For example, use a shorter journal time window:
sudo journalctl \
-t sshd \
-t sshd-session \
--since "1 hour ago" \
--no-pager
Look for event sequences involving the same username, source address, source port or process identifier.
A connection may generate several log lines. Five related entries do not necessarily represent five separate connections or five independent authentication attempts.
For more detailed guidance on filtering systemd logs, see journalctl Explained: How to Read Linux Service Logs and Find Errors.
7. What Does a Successful SSH Login Look Like?
Now consider a different example.
Oct 24 09:12:11 vps-lab sshd[6030]:
Accepted publickey for admin from
192.0.2.28 port 56088 ssh2
Illustrative, shortened log entry. Real public-key authentication logs may include the key algorithm and fingerprint.
This line tells us that the SSH server accepted public-key authentication for the account admin from the recorded client address.
That is materially different from Failed password.
But we still need to ask whether the authentication was expected.
Maybe it was your own login. Maybe a deployment system uses that account. Maybe you were connected through a VPN, meaning the recorded IP belongs to the VPN exit point rather than your home connection.
Or perhaps the login is unexplained.
To understand the situation, compare the timestamp, account and source against legitimate activity you know about.
Don’t assume that a foreign country in an IP geolocation database identifies an attacker. Geolocation is approximate, and clients may connect through cloud providers, corporate gateways and VPNs.
8. Can You Find Previous Successful Sessions?
On distributions with the relevant login accounting tools and records, last can display historical login sessions:
last -F -a | head -n 20
The output may include accounts, session timestamps, terminal identifiers, and remote host information.
These records are useful supporting evidence, but they have limitations. Login accounting may be absent, incomplete or subject to rotation, and not every type of SSH activity necessarily corresponds to an ordinary interactive login session.
To see users currently logged in, you can also run:
who
w
These show current session information, not a complete historical record of all SSH authentications.
If a suspicious login appears in one source but not another, don’t immediately conclude that a record was deleted. First account for the differences between authentication logs and session-accounting systems.
9. A Mini Investigation: Three Events, Three Conclusions
Let’s apply what we’ve learned to a hypothetical VPS.
Imagine you find these three observations in a day’s authentication history.
| Event | Initial interpretation | Next check |
|---|---|---|
| Failed password for an invalid user at 02:14 | Rejected authentication attempt. | Check whether this is isolated or part of a repeated pattern. |
| Multiple failures for a real account at 02:15 | Repeated rejected attempts involving that account. | Check for legitimate automation errors, other sources, and nearby successful logins. |
| Accepted publickey for admin at 09:12 | Successful public-key authentication. | Confirm who owns that login, which key was used when recorded, and whether the time and source are expected. |
Notice that the third event is not automatically malicious. It becomes concerning if you cannot match it to authorized activity.
This is the difference between collecting suspicious-looking messages and conducting a useful investigation.
You are not merely counting how many times the word Failed appears. You are building a coherent explanation from the evidence.
10. What If You Find an Unknown Successful Login?
If you discover a successful authentication that nobody authorized can explain, treat it as a potentially serious security incident until you can establish what occurred.
Start by recording the relevant timestamps, accounts, source addresses and log excerpts. Note the server’s timezone and whether multiple authentication sources agree.
Investigate whether the access can be explained by an administrator, VPN connection, hosting provider, backup service or deployment tool.
If the login remains unexplained, consider the possibility of unauthorized access and follow your organization’s incident-response procedure. Preserve relevant evidence and use a trusted management channel or provider console where appropriate.
Avoid randomly restarting SSH, deleting logs, removing accounts, or changing firewall rules while you are still establishing the facts. Those actions can destroy evidence or interrupt legitimate operations.
11. Why You Shouldn’t Immediately Disable SSH
It can be tempting to react to repeated failures by changing your SSH port, disabling password authentication, or blocking source addresses.
Some of those changes may be useful when carefully planned. But making them impulsively on a remote VPS can also remove your own access.
For example, disabling password authentication before confirming that your SSH key works can leave you unable to log in.
Similarly, a firewall rule that blocks your current management path can terminate access even if SSH itself is correctly configured.
This lesson is about recognizing what happened, not making untested configuration changes.
If your SSH connection is already failing, consult Can’t SSH Into Your Linux Server? 12 Checks Before You Reboot before trying random repairs.
We will cover a safer approach to hardening in the third lesson: validating an alternative access method, applying one change at a time and verifying that legitimate access still works.
12. Common Mistakes When Reading SSH Logs
Assuming every failure is an attack
A rejected authentication attempt alone doesn’t establish the client’s intent or identity.
Counting log lines as connections
One SSH connection can generate multiple messages and authentication attempts.
Ignoring time and context
Server timezone, journal retention and log rotation can affect incident reconstruction.
Sharing raw authentication logs
Logs can reveal usernames, infrastructure details, IP addresses and other information requiring careful handling.
Another common mistake is believing that an absence of SSH log entries proves that nobody contacted the server.
Connections can be filtered before SSH sees them. Logs may be written elsewhere, removed by retention policies or unavailable for a previous boot.
Read log evidence in combination with network exposure and authentication configuration.
13. What You Should Understand Before Securing SSH
Before changing your server, make sure you can answer five questions:
- Which SSH service is active, and how are you currently accessing it?
- Which user accounts actually need remote access?
- Are successful logins consistent with authorized administrators and automation?
- Which addresses and network paths can reach SSH?
- Do you have a verified recovery method if a change blocks remote access?
These answers provide a safer foundation for future changes.
For background on traffic filtering and the difference between a listening socket and an externally accessible service, revisit Linux Firewall Explained.
14. Frequently Asked Questions
Why are there SSH login attempts on a brand-new VPS?
A publicly reachable SSH endpoint may be discovered by automated internet scanners. Some clients attempt authentication even when the server is new and no domain name has been published. This is not proof that the server was compromised.
Does Failed password mean the attacker knows my password?
No. It means the server rejected a password authentication attempt. The message alone does not show that the client knew the correct password.
Does Accepted publickey always mean someone opened a shell?
No. It confirms accepted public-key authentication. Authorized SSH activity can include different session types, commands, file transfers and forwarding configurations. Additional evidence is needed to establish what followed.
Why are there no failed password messages?
Password authentication may be disabled or unavailable, clients may disconnect before authentication, traffic may be blocked earlier, or your current log query may not include the relevant messages. Absence of a particular log pattern does not prove absence of attempts.
Should I change SSH from port 22 to another port?
Changing the port can alter which automated scans reach the service, but it is not a substitute for strong authentication, patching and access controls. It must also be coordinated with firewalls and your management connection.
Can SSH logs tell me exactly who tried to log in?
Usually not. A source IP address identifies a network endpoint observed by the server, not necessarily the individual operating it. VPNs, NAT, shared networks and compromised hosts can complicate attribution.
15. What Comes Next?
We began with a collection of unfamiliar login attempts. Some messages showed invalid usernames. Others showed rejected passwords. We learned how to find authentication records and how to distinguish these failures from successful authentication.
But recognizing an event is only the second step.
Once you understand what the server is exposing and what its authentication records show, the next question becomes practical:
How do you reduce unnecessary SSH exposure and strengthen access controls without accidentally locking yourself out?
That is the focus of our final lesson.
Primary Technical Sources
- OpenSSH — sshd_config(5) — Authentication and logging configuration.
- Ubuntu Server — OpenSSH Server — OpenSSH administration and troubleshooting.
- systemd — journalctl — Journal filtering and inspection.
- Red Hat — How to Secure the SSHD Daemon? — Common SSH authentication threats.
A failed SSH login is evidence of an attempt, not proof of a breach.
Public servers can receive authentication requests from unfamiliar clients. The goal of a useful investigation is not to panic at every log message, but to understand which connections were rejected, which authentications succeeded and whether successful access was authorized.
First understand the evidence. Then make deliberate security changes.








