{"id":1875,"date":"2025-10-16T11:07:55","date_gmt":"2025-10-16T11:07:55","guid":{"rendered":"https:\/\/blog.eu.enginyr.ing\/?p=1875"},"modified":"2025-10-16T11:07:56","modified_gmt":"2025-10-16T11:07:56","slug":"how-to-detect-intruders-in-your-vps-server-complete-security-guide","status":"publish","type":"post","link":"https:\/\/www.serverspan.com\/en\/blog\/how-to-detect-intruders-in-your-vps-server-complete-security-guide\/","title":{"rendered":"How to Detect Intruders in Your VPS Server: Complete Security Guide"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Detecting intruders in your <a href=\"https:\/\/www.enginyring.com\/en\/virtual-servers\">VPS server<\/a> requires monitoring login attempts, checking system logs, identifying modified files, and analyzing running processes for suspicious activity. Every access to your server leaves traces you can find and analyze.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Professional system administrators use multiple detection methods working together. They check authentication logs for failed logins, review user databases for unauthorized accounts, monitor network ports for suspicious listeners, and deploy automated tools that alert when files change unexpectedly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Server security follows <strong>layered defense principles<\/strong> where each protection measure assumes all others have failed. This creates multiple barriers between attackers and your data.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Understanding layered security approach<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Security should never rely on a single protection mechanism. <strong>Layered security<\/strong> assumes that every defense will eventually fail and designs each layer as if it were the last line of protection.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This approach separates defenses so they operate independently without depending on each other. Comprehensive security protects multiple levels:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Data protection<\/strong>: encryption, hiding, backups<\/li>\n\n\n\n<li><strong>Application protection<\/strong>: updates, monitoring, logs<\/li>\n\n\n\n<li><strong>Service protection<\/strong>: databases, load balancers<\/li>\n\n\n\n<li><strong>Endpoint protection<\/strong>: firewalls, users, authorizations<\/li>\n\n\n\n<li><strong>Connection protection<\/strong>: WiFi, VLANs, network segmentation<\/li>\n\n\n\n<li><strong>Human element<\/strong>: training, policies, procedures<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The <strong>zero-trust security model<\/strong> embodies this philosophy by requiring every system component to verify every other component. While perfect zero-trust implementation remains impossible, the principle guides security architecture decisions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Each security layer must function effectively even when all other layers have been bypassed. This redundancy ensures attackers must defeat multiple independent defenses rather than exploiting a single weakness.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Signs someone accessed your server<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Every access to a computer leaves traces somewhere in the system. Attackers can gain entry through several methods:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Standard authentication methods like SSH<\/li>\n\n\n\n<li>Exploits that bypass security controls<\/li>\n\n\n\n<li>Backdoors installed during previous intrusions<\/li>\n\n\n\n<li>Physical access by stealing hard drives<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Understanding all these access vectors helps you know where to look for evidence. Start by examining logs for signs of intrusions, backdoors, or anything unusual.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Checking current and past logins<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Standard authentication methods get recorded in system logs. Non-standard methods like backdoors and exploits bypass normal authentication and may not appear in standard logs.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Check who is currently logged in:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>w<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This displays active user sessions with login times and current activities. Review this output for unexpected users, unusual login times outside business hours, or connections from unfamiliar IP addresses.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Review historical login records:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>last<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This command shows all past login sessions including:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Remote SSH logins<\/li>\n\n\n\n<li>Local console access<\/li>\n\n\n\n<li>System reboots<\/li>\n\n\n\n<li>Shutdown events<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The command reads binary log files that track authentication:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\/var\/log\/utmp<\/strong>: Current system status and active users<\/li>\n\n\n\n<li><strong>\/var\/log\/wtmp<\/strong>: Historical records of all login sessions<\/li>\n\n\n\n<li><strong>\/var\/log\/btmp<\/strong>: Failed login attempts<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Check failed login attempts:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>lastb<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">High volumes of failed attempts from the same IP address indicate automated attack tools scanning for weak passwords.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>See when each user last logged in:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>lastlog<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This helps identify dormant accounts that suddenly become active or accounts that have never been used legitimately.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Examining user and password databases<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">User account information lives in two critical files:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\/etc\/passwd<\/strong>: User details (readable by everyone)<\/li>\n\n\n\n<li><strong>\/etc\/shadow<\/strong>: Password hashes (readable only by root)<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Inspect the shadow file:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat \/etc\/shadow<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The password field uses a format: <strong>algorithm-ID.cost-factor.salt.hash<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Modern systems use strong hashing algorithms:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>y<\/strong> = yescrypt (recommended)<\/li>\n\n\n\n<li><strong>6<\/strong> = SHA-512<\/li>\n\n\n\n<li><strong>5<\/strong> = SHA-256<\/li>\n\n\n\n<li><strong>1<\/strong> = MD5 (outdated, insecure)<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Important password field symbols:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>*<\/strong> = No password assigned, account cannot authenticate<\/li>\n\n\n\n<li><strong>!<\/strong> = Account temporarily disabled<\/li>\n\n\n\n<li>Invalid format = Login prevented<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Review \/etc\/shadow for unauthorized user accounts, especially those with <strong>UID 0<\/strong> granting root privileges, or accounts with suspicious password values.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Identifying suspicious processes<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Attackers execute malicious code that runs as processes in system memory. These processes continue running even if the original binary file gets deleted from disk.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Show all running processes:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ps afxu<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This displays user ownership, CPU usage, memory consumption, and command lines.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Use interactive monitoring tools:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>htop\n# or\nbtop<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>What to look for:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Unfamiliar process names<\/li>\n\n\n\n<li>Processes owned by unexpected users<\/li>\n\n\n\n<li>Processes running from \/tmp or \/var\/tmp directories<\/li>\n\n\n\n<li>Legitimate processes typically run from \/usr\/bin, \/usr\/sbin, or \/bin<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Terminate suspicious processes:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>kill -9 &lt;process_id&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The <strong>-9 signal<\/strong> forces immediate termination that processes cannot intercept or ignore.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Kill all processes of a specific user:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>killall -u &lt;username&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Analyzing authentication logs<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">All Linux system logs concentrate in <strong>\/var\/log\/<\/strong> directory. Authentication information appears in specific log files you should check regularly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Check authentication logs:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>grep user \/var\/log\/auth.log | grep -vi cron | less<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Find failed password attempts:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>grep -i \"Failed password\" \/var\/log\/auth.log<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Check system-wide logs:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat \/var\/log\/syslog | less<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>For compressed rotated logs:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>zgrep user \/var\/log\/auth.log.2.gz | grep -vi cron | less<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>What to look for in logs:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Unusual login times (middle of night, weekends)<\/li>\n\n\n\n<li>Geographic patterns inconsistent with legitimate usage<\/li>\n\n\n\n<li>Sudden increases in failed authentication attempts<\/li>\n\n\n\n<li>Successful logins immediately following many failures<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Finding recently modified files<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Knowing which files changed after an attack proves critical for damage assessment. The <strong>find<\/strong> command searches for files based on modification time.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Files modified in the last 24 hours:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>find \/ -mtime 0 -ls | grep -v \"proc\\|sys\" | less<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Files modified within last 48 hours:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>find \/ -mtime -2 -ls | grep -v \"proc\\|sys\" | less<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Files modified in the last week:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>find \/ -mtime -7 -ls | grep -v \"proc\\|sys\" | less<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Understanding -mtime syntax:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>-mtime 0<\/strong>: Exactly the last 24 hours<\/li>\n\n\n\n<li><strong>-mtime -N<\/strong>: Less than N days ago<\/li>\n\n\n\n<li><strong>-mtime +N<\/strong>: More than N days ago<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Check detailed file timestamps:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>stat \/etc\/passwd<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This shows access time, modify time, change time, and birth time.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Critical directories to monitor:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\/etc<\/strong>: Configuration files<\/li>\n\n\n\n<li><strong>\/bin<\/strong> and <strong>\/usr\/bin<\/strong>: Executables<\/li>\n\n\n\n<li><strong>\/root<\/strong> and <strong>\/home<\/strong>: User data<\/li>\n\n\n\n<li>Web server document roots<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Checking for backdoors<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Backdoors allow attackers to regain access after their initial entry point gets discovered and closed. Check multiple locations where backdoors commonly hide.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Check SSH authorized keys:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat ~\/.ssh\/authorized_keys<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Unauthorized keys in this file grant silent access bypassing password requirements.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Check startup scripts:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>less \/etc\/rc.local\nless \/etc\/profile\nls \/etc\/profile.d\/*\ncat ~\/.bashrc\ncat ~\/.zshrc<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Review cron jobs:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># User crontabs\ncrontab -l\n\n# System crontabs\ncat \/etc\/crontab\nls \/etc\/cron.d\/\nls \/etc\/cron.daily\/\nls \/etc\/cron.hourly\/\nls \/etc\/cron.weekly\/\nls \/etc\/cron.monthly\/<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Check systemd services:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl list-unit-files --type=service | grep enabled<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Check open network ports:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ss -anpult<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>What to look for:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>LISTEN processes in TCP<\/li>\n\n\n\n<li>Any UDP processes<\/li>\n\n\n\n<li>Unexpected ports (especially high-numbered ports)<\/li>\n\n\n\n<li>Processes without clear legitimate purpose<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Hardening SSH access<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">SSH represents the primary remote access method for <a href=\"https:\/\/www.enginyring.com\/en\/virtual-servers\">VPS servers<\/a>, making SSH security critical. Configure SSH through <strong>\/etc\/ssh\/sshd_config<\/strong> with settings that restrict access and enforce strong authentication.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Generate SSH keys on your local computer:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh-keygen<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Copy public key to server:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh-copy-id -p 22 root@your-server.com<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Edit SSH configuration:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vi \/etc\/ssh\/sshd_config<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Critical SSH security settings:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>PasswordAuthentication no<\/strong> &#8211; Force public key authentication<\/li>\n\n\n\n<li><strong>PermitRootLogin no<\/strong> &#8211; Prevent direct root login<\/li>\n\n\n\n<li><strong>AllowUsers username<\/strong> &#8211; Restrict to specific users<\/li>\n\n\n\n<li><strong>DenyUsers username<\/strong> &#8211; Explicitly block certain users<\/li>\n\n\n\n<li><strong>AllowGroups sshusers<\/strong> &#8211; Allow only specific groups<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Reload SSH (not restart!):<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/etc\/init.d\/ssh reload<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Important:<\/strong> Always test with a backup connection open! If new settings prevent connection, you can revert through your backup session.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Enforce strong passwords:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vi \/etc\/pam.d\/common-password<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Add this line:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>password requisite pam_pwquality.so retry=3 minlen=20 difok=3 dcredit=3 ucredit=3 lcredit=3<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Parameters explained:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>retry=3<\/strong>: Attempt limit<\/li>\n\n\n\n<li><strong>minlen=20<\/strong>: Minimum length<\/li>\n\n\n\n<li><strong>difok=3<\/strong>: Maximum reused characters from old password<\/li>\n\n\n\n<li><strong>dcredit=3<\/strong>: Minimum numerals required<\/li>\n\n\n\n<li><strong>ucredit=3<\/strong>: Minimum uppercase characters<\/li>\n\n\n\n<li><strong>lcredit=3<\/strong>: Minimum lowercase characters<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Configuring file permissions<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Linux file permissions control read, write, and execute access separately for the file owner, group members, and all other users.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Check permissions:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls -alh \/etc<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Permission types:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>r (read)<\/strong>: View file contents or list directory<\/li>\n\n\n\n<li><strong>w (write)<\/strong>: Modify file or create\/delete files in directory<\/li>\n\n\n\n<li><strong>x (execute)<\/strong>: Run executable or enter directory<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Change permissions:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>chmod u+x filename      # Add execute for user\nchmod go-w filename     # Remove write from group and others\nchmod 644 filename      # Set specific permissions (rw-r--r--)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Critical file permission recommendations:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\/etc\/shadow<\/strong>: 600 (root only)<\/li>\n\n\n\n<li><strong>\/etc\/passwd<\/strong>: 644 (readable by all)<\/li>\n\n\n\n<li><strong>Home directories<\/strong>: 700 or 750<\/li>\n\n\n\n<li><strong>Web files<\/strong>: 644 for files, 755 for directories<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Understanding umask<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Umask sets default permissions for newly created files and directories system-wide.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Check current umask:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>umask\n# or\numask -S  # Symbolic notation<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Set new umask:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>umask 026<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>How umask works:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Files default to <strong>666<\/strong> permissions<\/li>\n\n\n\n<li>Directories default to <strong>777<\/strong> permissions<\/li>\n\n\n\n<li>Umask subtracts from these defaults<\/li>\n\n\n\n<li>Example: 666 &#8211; 026 = 640 (rw-r&#8212;&#8211;)<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">File attributes and extended attributes<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">File attributes provide metadata controlling what operations are allowed beyond standard permissions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>View attributes:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>lsattr filename<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Useful attributes:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>a<\/strong>: Append-only (file can only be appended)<\/li>\n\n\n\n<li><strong>i<\/strong>: Immutable (cannot be modified or deleted)<\/li>\n\n\n\n<li><strong>A<\/strong>: No atime update (improves performance)<\/li>\n\n\n\n<li><strong>s<\/strong>: Secure deletion (overwrite on delete)<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Change attributes:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>chattr +i filename      # Make immutable\nchattr -i filename      # Remove immutable<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Extended attributes (user space):<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>setfattr -n user.note -v \"this is mine\" file.txt\ngetfattr -n user.note file.txt\ngetfattr -d file.txt    # Show all attributes<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Access Control Lists (ACL)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">ACLs provide more specific permission control than traditional Unix permissions, allowing multiple users and groups with different access levels.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>View ACLs:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>getfacl filename<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Set ACL for specific user:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>setfacl -m u:username:rwx \/path\/to\/directory<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Remove ACL entry:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>setfacl -x u:username \/path\/to\/directory<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Default ACLs for directories:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>setfacl -d -m u:username:rwx \/path\/to\/directory<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The <strong>+<\/strong> symbol after permissions in ls -l indicates ACL entries exist.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Automated intrusion detection with AIDE<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">AIDE (Advanced Intrusion Detection Environment) automates file integrity checking by creating snapshot databases of file properties. It detects unauthorized additions, deletions, and modifications.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Install AIDE:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt install aide<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Initialize database:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>aide --init --config=\/etc\/aide\/aide.conf<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This can take hours on large systems. Be patient!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Activate the database:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cp \/var\/lib\/aide\/aide.db.new \/var\/lib\/aide\/aide.db<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Run checks:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>aide --check --config=\/etc\/aide\/aide.conf<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>AIDE output indicators:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>+<\/strong> = Added files<\/li>\n\n\n\n<li><strong>&#8211;<\/strong> = Removed files<\/li>\n\n\n\n<li><strong>Changed attributes<\/strong>: p=permissions, u=user, g=group, m=modification time, c=change time, C=checksums<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Update database after legitimate changes:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>aide --update --config=\/etc\/aide\/aide.conf\ncp \/var\/lib\/aide\/aide.db.new \/var\/lib\/aide\/aide.db<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Schedule daily checks with cron:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>crontab -e<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Add:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>0 2 * * * \/usr\/bin\/aide --check --config=\/etc\/aide\/aide.conf<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Important:<\/strong> Store baseline databases offline! Attackers with root access can modify local AIDE databases to hide their tracks.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Automated security auditing with Lynis<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Lynis performs comprehensive automated security audits scanning for vulnerabilities, misconfigurations, and security weaknesses.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Install Lynis:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git clone https:\/\/github.com\/CISOfy\/lynis.git\ncd lynis<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Run full audit:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.\/lynis audit system<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>What Lynis checks:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Password policies<\/li>\n\n\n\n<li>Firewall configurations<\/li>\n\n\n\n<li>Running services<\/li>\n\n\n\n<li>Kernel parameters<\/li>\n\n\n\n<li>Logging setup<\/li>\n\n\n\n<li>Installed security tools<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Lynis generates a <strong>hardening index score<\/strong> reflecting overall security posture. Higher scores indicate better configurations.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Benefits of Lynis:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Runs safely without modifying settings<\/li>\n\n\n\n<li>Generates detailed reports with severity ratings<\/li>\n\n\n\n<li>Provides specific hardening recommendations<\/li>\n\n\n\n<li>Safe for production environments<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Schedule Lynis audits <strong>monthly<\/strong> or after major system changes to track security posture over time.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Log analysis with Logwatch<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Logwatch automatically analyzes system logs generating human-readable reports summarizing important events.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Install Logwatch:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt install logwatch<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Run comprehensive analysis:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>logwatch --service all --detail High --range All<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Detail levels:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Low<\/strong>: Critical events only<\/li>\n\n\n\n<li><strong>Medium<\/strong>: Important warnings<\/li>\n\n\n\n<li><strong>High<\/strong>: All noteworthy entries<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Time ranges:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Today<\/strong>: Last 24 hours<\/li>\n\n\n\n<li><strong>Yesterday<\/strong>: Previous day<\/li>\n\n\n\n<li><strong>All<\/strong>: Complete historical analysis<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>What Logwatch reports highlight:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Failed login attempts<\/li>\n\n\n\n<li>Service errors<\/li>\n\n\n\n<li>Disk space issues<\/li>\n\n\n\n<li>Unusual system events<\/li>\n\n\n\n<li>Security-relevant activities<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Configure Logwatch to email daily summaries to administrators for routine security awareness without requiring manual log review.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How ENGINYRING VPS supports security<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/www.enginyring.com\/en\/virtual-servers\">ENGINYRING VPS plans<\/a> provide <strong>full root access<\/strong> enabling complete control over security configurations. You can install and configure any security tools required for your environment.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Security advantages:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Complete control<\/strong>: SSH hardening, firewall rules, intrusion detection<\/li>\n\n\n\n<li><strong>Isolated environment<\/strong>: Your security measures protect only your resources<\/li>\n\n\n\n<li><strong>DDoS protection<\/strong>: Network-level filtering before traffic reaches your VPS<\/li>\n\n\n\n<li><strong>Automated <a href=\"https:\/\/www.enginyring.com\/en\/blog\/the-ultimate-guide-to-vps-backups-strategies-tools-and-best-practices\">backups<\/a><\/strong>: Recovery points for restoration after incidents<\/li>\n\n\n\n<li><strong>Dedicated resources<\/strong>: Guaranteed CPU, memory, disk throughput<\/li>\n\n\n\n<li><strong>Technical support<\/strong>: Installation assistance and incident response guidance<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The combination of full administrative control and robust infrastructure creates optimal conditions for implementing <a href=\"https:\/\/www.enginyring.com\/en\/blog\/the-ultimate-vps-security-guide-from-essential-hardening-to-elite-sysadmin-secrets\">enterprise-grade security practices<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Maintaining ongoing security vigilance<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Security is not a one-time configuration but an <strong>ongoing process<\/strong> requiring constant vigilance and adaptation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Regular security schedule:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Daily<\/strong>: AIDE checks, log review with Logwatch<\/li>\n\n\n\n<li><strong>Weekly<\/strong>: Manual log analysis, process review<\/li>\n\n\n\n<li><strong>Monthly<\/strong>: Lynis security audits, permission audits<\/li>\n\n\n\n<li><strong>As needed<\/strong>: Software updates, critical security patches<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Document your security baseline:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Authorized users and their access levels<\/li>\n\n\n\n<li>Required services and listening ports<\/li>\n\n\n\n<li>Legitimate remote access sources (IP addresses)<\/li>\n\n\n\n<li>Normal traffic patterns and usage times<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">This documented baseline makes anomaly detection significantly easier. When something unusual appears, compare against your baseline to quickly determine if it&#8217;s legitimate or suspicious.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Practice incident response:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Run tabletop exercises simulating attack scenarios<\/li>\n\n\n\n<li>Test backup restoration before needing it during incidents<\/li>\n\n\n\n<li>Verify monitoring alerts reach appropriate personnel<\/li>\n\n\n\n<li>Document response procedures and update regularly<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Effective security combines <strong>technical controls<\/strong> with procedural discipline and continuous learning about evolving threats and defensive techniques.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Detecting intruders in your VPS server requires monitoring login attempts, checking system logs, identifying modified files, and analyzing running processes for suspicious activity. Every access to your server leaves traces you can find and analyze. Professional system administrators use multiple detection methods working together. They check authentication logs for failed logins, review user databases for [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1876,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,12],"tags":[11391,11384,11402,11396,11398,11381,8909,11390,11404,11382,11389,11385,8902,11399,11393,11392,11401,11388,11394,11403,11397,11387,5419,11383,4194,11400,11395,11386,11380,9438],"class_list":["post-1875","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","category-virtual-servers","tag-acl-access-control","tag-aide-intrusion-detection","tag-authentication-log-analysis","tag-automated-security-audit","tag-cron-job-security","tag-detect-server-intrusions","tag-file-integrity-monitoring","tag-file-permissions-linux","tag-intrusion-prevention-system","tag-linux-security-audit","tag-linux-user-management","tag-log-analysis-tools","tag-lynis-security-audit","tag-malware-detection-linux","tag-network-port-monitoring","tag-process-monitoring-linux","tag-root-access-protection","tag-security-backdoor-detection","tag-security-incident-response","tag-server-compromise-detection","tag-server-hardening-guide","tag-server-log-monitoring","tag-server-security-monitoring","tag-ssh-hardening-vps","tag-ssh-key-authentication","tag-system-administrator-security","tag-systemd-service-security","tag-unauthorized-access-detection","tag-vps-intrusion-detection","tag-vps-security-best-practices"],"_links":{"self":[{"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1875","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1875"}],"version-history":[{"count":1,"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1875\/revisions"}],"predecessor-version":[{"id":1877,"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1875\/revisions\/1877"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=\/wp\/v2\/media\/1876"}],"wp:attachment":[{"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1875"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1875"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.serverspan.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1875"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}