How to Detect Hidden Persistence, Unauthorized SSH Access, Suspicious Processes, and Malicious System Changes Before Attackers Regain Control
Your Linux server is running. Your website is accessible. CPU and memory usage appear normal. No major service failures have been reported.
Everything looks healthy.
But does that mean your server is secure?
Not necessarily.
An attacker who successfully compromises a Linux server may attempt to maintain access even after the initial security weakness has been addressed. They may introduce unauthorized SSH keys, create scheduled tasks, modify system services, or manipulate startup configurations.
These activities can remain unnoticed if security monitoring focuses only on server uptime, resource usage, or failed login attempts.
This is where Linux Persistence Detection becomes essential.
For cybersecurity analysts and Linux administrators, understanding how attackers maintain access is just as important as detecting how they initially entered a system.
In this article, we explore seven warning signs that may indicate unauthorized persistence or suspicious activity inside a Linux server, along with practical investigation techniques.
1. Unauthorized SSH Keys: Someone Else May Have Access
SSH key authentication is one of the most widely used methods for securely accessing Linux servers.
However, improperly managed SSH keys can become a serious security risk.
An attacker who obtains sufficient access to a server may attempt to add an unauthorized public key to an account's authorized_keys file.
If the corresponding private key is available to the attacker, they may be able to authenticate using that account.
Important locations to investigate:
~/.ssh/authorized_keys/root/.ssh/authorized_keys- Other users' SSH directories
- SSH server configuration
Practical investigation:
Find authorized key files:
sudo find /home /root \
-path '*/.ssh/authorized_keys' -type f 2>/dev/nullInspect a specific file:
sudo cat /root/.ssh/authorized_keysCheck file metadata:
sudo stat /root/.ssh/authorized_keysReview SSH authentication events:
sudo grep -E "Accepted|Failed|Invalid user" \
/var/log/auth.log | tail -50What should security analysts look for?
- Unexpected public key additions.
- Changes to previously approved SSH keys.
- New or unfamiliar user accounts with SSH access.
- Authentication from unexpected IP addresses.
- Unusual login times.
An authorized key change is not automatically malicious. Analysts should compare it against approved access records and historical baselines.
2. Suspicious Cron Jobs: Hidden Scheduled Activity
Cron is a standard Linux scheduling mechanism used to execute tasks automatically.
Administrators use it for:
- Database backups.
- Log rotation.
- System maintenance.
- Application scheduling.
- Automated scripts.
However, attackers may also abuse scheduled tasks to maintain unauthorized activity.
An unexpected Cron Job could execute a suspicious script at regular intervals or during specific system conditions.
Important locations:
/etc/crontab/etc/cron.d//etc/cron.hourly//etc/cron.daily/- User-specific crontabs.
Practical investigation:
List system Cron directories:
sudo ls -la /etc/cron.d/Inspect the main Cron configuration:
sudo cat /etc/crontabCheck the current user's scheduled tasks:
sudo crontab -lList available user Cron files:
sudo ls -la /var/spool/cron/crontabs/Warning signs:
- Unexpected scheduled tasks.
- Unknown script references.
- Unfamiliar execution paths.
- Unexpected changes to existing Cron entries.
- Jobs executing under privileged accounts without a clear operational reason.
Analysts should inspect the actual command, referenced script, ownership, execution schedule, and change history before classifying an entry as malicious.
3. Unknown Systemd Services: Persistence Beyond Reboots
Systemd manages services and system processes on many modern Linux distributions.
It controls services such as Nginx, MySQL, SSH, and other background applications.
An attacker may attempt to create or modify a systemd service to maintain unauthorized execution.
A suspicious service may be configured to start automatically when the system boots or restart under certain conditions.
Important location:
/etc/systemd/system/Practical investigation:
List enabled services:
systemctl list-unit-files --state=enabledList currently running services:
systemctl --type=service --state=runningInspect a specific service:
systemctl status service-nameReview its configuration:
sudo systemctl cat service-nameInspect recently modified systemd files:
sudo find /etc/systemd/system/ \
-type f -mtime -7 -lsWhat should analysts investigate?
- Newly created service files.
- Unexpected changes to existing services.
- Executables running from unusual locations.
- Unknown service owners or package origins.
- Unexpected restart behaviour.
- Services running with excessive privileges.
A newly installed application may legitimately create a service. The objective is to identify unexplained changes, not flag every new service as an attack.
4. Modified Shell Startup Files: Hidden Commands During Login
Linux shell environments use configuration files to initialise user sessions.
Common examples include:
.bashrc.bash_profile.profile.bash_login.zshrc.zprofile
These files may contain environment variables, aliases, shell configuration, and startup commands.
An attacker with sufficient permissions may attempt to modify these files to introduce unauthorized commands that execute when a relevant shell session starts.
Practical investigation:
Find common shell startup files:
sudo find /home /root -type f \
\( -name ".bashrc" -o \
-name ".bash_profile" -o \
-name ".profile" -o \
-name ".bash_login" -o \
-name ".zshrc" -o \
-name ".zprofile" \) 2>/dev/nullInspect a specific file:
cat ~/.bashrcCheck modification details:
stat ~/.bashrcWhat should security analysts look for?
- Unexpected startup commands.
- Unknown script references.
- Unfamiliar environment variables.
- Suspicious modifications.
- Commands that initiate unexpected network communication.
The key is to understand what changed and whether the modification was part of an authorised administrative operation.
5. Suspicious Running Processes: What Is Actually Running on Your Server?
A Linux server can appear operational while running an unauthorized background process.
Some malicious processes may consume significant resources. Others may deliberately operate with minimal resource usage to avoid attention.
Potential concerns include:
- Unauthorized cryptocurrency miners.
- Suspicious background scripts.
- Unrecognised executables.
- Unexpected parent-child process relationships.
- Processes communicating with unfamiliar destinations.
Practical investigation:
View the highest CPU-consuming processes:
ps aux --sort=-%cpu | head -20Inspect a specific process:
ps -fp PIDIdentify its executable:
sudo readlink -f /proc/PID/exeInspect its process details:
sudo cat /proc/PID/statusWhat should analysts investigate?
- Unexpected executables.
- Processes running under unusual accounts.
- Suspicious executable locations.
- Unusual parent-child relationships.
- Unexpected network connections.
- Abnormal resource consumption.
A process name alone is not reliable evidence. File hashes, executable paths, process ancestry, user context, and behavioural indicators provide stronger investigation context.
6. Unusual Network Connections: Is Your Server Communicating With an Unknown Destination?
One of the most important indicators of suspicious server activity is unexpected network communication.
A compromised server may communicate with external infrastructure for various reasons, including command-and-control activity or data transfer.
However, legitimate applications also communicate with external services.
This makes contextual analysis essential.
Practical investigation:
View active TCP and UDP connections:
sudo ss -tunapIdentify listening services:
sudo ss -tulpnReview processes using network connections:
sudo lsof -i -n -PWarning signs:
- Unexpected outbound connections.
- Unknown remote destinations.
- New listening ports.
- Unusual communication patterns.
- Network activity from unfamiliar processes.
- Significant outbound traffic outside normal operating periods.
Security analysts should compare network activity against known application dependencies, normal traffic patterns, and approved infrastructure configurations.
7. Rootkit Indicators: When Normal Monitoring May Not Be Enough
Rootkits represent a more advanced category of security threat.
Depending on their implementation and privileges, rootkits may attempt to conceal processes, files, network activity, or other evidence of compromise.
This creates a serious challenge for traditional monitoring tools.
A compromised system may not always report its internal state accurately.
Some useful investigation tools include:
rkhunter
sudo apt install rkhunter
sudo rkhunter --checkchkrootkit
sudo apt install chkrootkit
sudo chkrootkitLynis
sudo apt install lynis
sudo lynis audit systemThese tools help identify potential indicators, configuration weaknesses, and suspicious system conditions.
However, no single tool guarantees rootkit detection.
False positives are possible, and advanced kernel-level compromises may evade tools running inside the affected operating system.
For high-confidence investigations, analysts may need trusted external boot environments, offline inspection, and forensic analysis.
8. The Real Challenge: Connecting Individual Warning Signs
Detecting one suspicious change is useful.
Connecting several related events can reveal a much larger security incident.
Consider the following example:
An organisation manages three Linux servers.
Server A — Web Server
An unfamiliar SSH key modification is detected.
Server B — Application Server
An unexpected Cron Job appears shortly afterwards.
Server C — Database Server
An unusual process begins communicating with an unfamiliar external destination.
These events may have separate legitimate explanations.
But if the servers share access relationships, and the events occur within a suspicious sequence, they deserve a coordinated investigation.
A security analyst should ask:
- Which event occurred first?
- Which accounts were involved?
- Did the servers communicate with each other?
- Were credentials or SSH keys shared?
- Were new persistence mechanisms introduced?
- Is there evidence of unauthorised data access?
- Do other servers show related indicators?
This is why centralised monitoring and cross-server event correlation are important.
Security teams need visibility into the complete infrastructure, not just individual machines.
9. How to Build Effective Linux Persistence Monitoring
A reliable persistence monitoring solution should establish a baseline of expected system behaviour and continuously identify meaningful changes.
Important monitoring areas include:
| Monitoring Area | Security Objective |
|---|---|
| SSH Keys | Detect unauthorized access changes |
| Cron Jobs | Identify unexpected scheduled tasks |
| Systemd Services | Detect suspicious service modifications |
| Shell Startup Files | Identify unexpected startup changes |
| Running Processes | Investigate suspicious execution |
| Network Connections | Identify unusual communication |
| Critical Files | Monitor important configuration changes |
Baseline Monitoring
Record the expected state of important system artifacts.
For example:
- Approved SSH keys.
- Existing Cron Jobs.
- Known systemd services.
- Trusted startup configurations.
- Expected file permissions and ownership.
Change Detection
Compare current system state against the established baseline.
Evidence Collection
Capture useful investigation details:
- File path.
- Modification timestamp.
- File hash.
- Ownership.
- Permissions.
- Relevant configuration changes.
Risk Assessment
Evaluate changes based on their context, importance, and associated indicators.
Centralised Alerts
Send relevant security findings to a central monitoring environment so analysts can investigate activity across multiple servers.
Importantly, persistence monitoring should preserve investigation evidence and avoid automatically modifying or deleting system files unless a separately authorised response procedure requires it.
10. Why DEFENSOR Focuses on Linux Persistence Monitoring
For organisations managing multiple Linux servers, identifying unauthorised changes across the infrastructure can become challenging.
DEFENSOR is designed to provide centralised Linux security monitoring and help security teams investigate suspicious activities across their managed server environments.
Its security monitoring capabilities include areas such as:
- Linux persistence artifact inspection.
- SSH and authentication monitoring.
- Suspicious activity identification.
- YARA-based malware pattern detection.
- Vulnerability intelligence.
- Security event visibility.
- Centralised incident management.
- Multi-server monitoring.
Through its Linux monitoring approach, DEFENSOR helps security teams gain visibility into important system changes without relying entirely on manual server-by-server inspection.
The objective is to help administrators and security analysts identify suspicious behaviour, review supporting evidence, and investigate potential threats.
Because monitoring server availability is not the same as monitoring server security.
Explore DEFENSOR:
11. A Security Analyst's Final Checklist
Before considering a Linux server secure, review these questions:
- Are all SSH authorised keys approved?
- Are there any unexplained Cron Jobs?
- Are all enabled Systemd services recognised?
- Have shell startup files changed unexpectedly?
- Are unfamiliar processes running?
- Are there unexpected network connections?
- Have any rootkit indicators been reported?
- Are important system files monitored for changes?
- Are suspicious events correlated across multiple servers?
- Is there sufficient evidence to support the security assessment?
A server should not be considered secure simply because its applications are running normally.
Security requires continuous visibility into what is happening beneath the surface.
Conclusion: A Healthy Server Does Not Always Mean a Secure Server
Modern Linux security requires more than monitoring CPU usage, memory consumption, disk space, and service availability.
Attackers may attempt to maintain access through SSH keys, scheduled tasks, system services, startup configurations, and suspicious background processes.
These changes can remain unnoticed when security monitoring focuses only on traditional infrastructure metrics.
For Linux administrators, cybersecurity analysts, and SOC teams, persistence detection should be an essential part of continuous security monitoring.
The most important lesson is simple:
Don't just monitor whether your server is running. Monitor what is changing inside it.
Investigate unexpected changes. Understand suspicious behaviour. Correlate security events across your infrastructure.
Because sometimes, the biggest threat to your Linux server is not the attacker trying to get in.
It is the attacker who may already be inside.
DEFENSOR — Monitor Beyond Alerts. Defend Beyond Servers.