Malware & Rootkit Scanning: rkhunter and ClamAV Guide
Protect your Linux server against malware and rootkits. rkhunter and ClamAV installation, scan configuration, result interpretation, scheduled scans, and incident response guide.
Zero Trust network security principles and practical implementation: never trust always verify, micro-segmentation, identity-based access, and implementation with existing Linux tools.
The traditional network security model trusts everything inside the internal network. The Zero Trust model advocates the opposite: "Never trust, always verify." This approach is critically important in modern cloud and hybrid environments. This guide shows you how to implement Zero Trust principles using existing Linux tools.
Zero Trust is a security model defined by Forrester Research analysts in 2010. Its core assumption is: No user, device, or service inside or outside the network is automatically trusted.
| Feature | Traditional | Zero Trust |
|---|---|---|
| Trust model | Trust internal network | Trust nothing |
| Authentication | At network perimeter | On every access |
| Access control | IP-based | Identity-based |
| Segmentation | Flat network | Micro-segmentation |
| Monitoring | Perimeter-focused | Everywhere |
Using certificates instead of passwords is a cornerstone of Zero Trust.
# Create SSH CA (Certificate Authority)
mkdir -p /etc/ssh/ca
cd /etc/ssh/ca
# Create CA key pair
ssh-keygen -t ed25519 -f ssh_ca -C "SSH Certificate Authority"
# Sign user key
ssh-keygen -s /etc/ssh/ca/ssh_ca \
-I "user@hostname" \
-n username \
-V +52w \
~/.ssh/id_ed25519.pub
# View certificate
ssh-keygen -L -f ~/.ssh/id_ed25519-cert.pub
# Zero Trust SSH configuration
# Disable password login
PasswordAuthentication no
ChallengeResponseAuthentication no
# Certificate-based authentication
TrustedUserCAKeys /etc/ssh/ca/ssh_ca.pub
# Disable root login
PermitRootLogin no
# Allow only specific users
AllowUsers deploy admin
# Session timeout
ClientAliveInterval 300
ClientAliveCountMax 2
# Restrict inter-service communication
# Example: Web server can only connect to database
# Default policies
sudo iptables -P INPUT DROP
sudo iptables -P FORWARD DROP
sudo iptables -P OUTPUT ACCEPT
# Allow loopback
sudo iptables -A INPUT -i lo -j ACCEPT
# Allow established connections
sudo iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# SSH access (management network only)
sudo iptables -A INPUT -p tcp --dport 22 -s 10.0.1.0/24 -j ACCEPT
# Web server (public)
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 443 -j ACCEPT
# Database (web server only)
sudo iptables -A INPUT -p tcp --dport 3306 -s 10.0.2.10 -j ACCEPT
# Redis (application server only)
sudo iptables -A INPUT -p tcp --dport 6379 -s 10.0.2.0/24 -j ACCEPT
# Log and drop everything else
sudo iptables -A INPUT -j LOG --log-prefix "DROPPED: "
sudo iptables -A INPUT -j DROP
# Multi-factor authentication with PAM
sudo apt install libpam-google-authenticator -y
# Set up TOTP for user
google-authenticator
# PAM configuration
sudo nano /etc/pam.d/sshd
# /etc/pam.d/sshd
auth required pam_google_authenticator.so
# Enable MFA in SSH config
ChallengeResponseAuthentication yes
AuthenticationMethods publickey,keyboard-interactive
# Install auditd
sudo apt install auditd -y
# Monitor critical files
sudo auditctl -w /etc/passwd -p wa -k passwd_changes
sudo auditctl -w /etc/shadow -p wa -k shadow_changes
sudo auditctl -w /etc/sudoers -p wa -k sudoers_changes
# Monitor network connections
sudo auditctl -a always,exit -F arch=b64 -S connect -k network_connect
# View audit logs
sudo ausearch -k passwd_changes
sudo aureport --auth
# Create separate user for each service
sudo useradd -r -s /bin/false -d /var/lib/myapp myapp
# Specify user in service file
sudo nano /etc/systemd/system/myapp.service
[Service]
User=myapp
Group=myapp
NoNewPrivileges=true
PrivateTmp=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/var/lib/myapp
CapabilityBoundingSet=
AmbientCapabilities=
# Each application runs in its own network
docker network create --driver bridge --subnet 172.20.0.0/24 frontend-net
docker network create --driver bridge --subnet 172.21.0.0/24 backend-net
docker network create --driver bridge --subnet 172.22.0.0/24 db-net
# Containers connect only to required networks
docker run --network frontend-net nginx
docker run --network backend-net,frontend-net myapp
docker run --network db-net postgres
Zero Trust implementation is a gradual process:
#!/bin/bash
# Zero Trust security check script
echo "=== Zero Trust Security Check ==="
# Is SSH password login disabled?
if grep -q "PasswordAuthentication no" /etc/ssh/sshd_config; then
echo "[OK] SSH password login disabled"
else
echo "[WARNING] SSH password login enabled!"
fi
# Is root login disabled?
if grep -q "PermitRootLogin no" /etc/ssh/sshd_config; then
echo "[OK] SSH root login disabled"
else
echo "[WARNING] SSH root login enabled!"
fi
# Is firewall active?
if sudo ufw status | grep -q "Status: active"; then
echo "[OK] UFW firewall active"
else
echo "[WARNING] UFW firewall inactive!"
fi
# Is Fail2Ban running?
if systemctl is-active --quiet fail2ban; then
echo "[OK] Fail2Ban running"
else
echo "[WARNING] Fail2Ban not running!"
fi
echo "Check complete."
Zero Trust is a philosophy, not a product. Start with existing tools and gradually increase your maturity level. Aim for continuous improvement rather than perfection.
Zero Trust is a comprehensive security approach required by modern security threats. It's possible to implement basic Zero Trust principles with Linux tools. SSH certificates, micro-segmentation, MFA, and continuous monitoring can significantly strengthen your security posture.
Zero Trust can be implemented gradually. Start with SSH key-based authentication and basic firewall rules. Over time, add MFA, micro-segmentation, and continuous monitoring. Each step improves security.
Yes, but Zero Trust can replace VPN. Traditional VPN provides broad access once inside the network. Zero Trust requires separate authentication for each resource. Modern VPNs like WireGuard can be configured in alignment with Zero Trust principles.
Yes, it's even more critical for small servers. Even on a single server, implementing SSH key-based authentication, Fail2Ban, and basic firewall rules forms the foundation of Zero Trust and significantly reduces the attack surface.
Modern iptables/nftables rules have very low overhead. Properly configured micro-segmentation has negligible performance impact. However, very complex rule sets can create management challenges.
In the Linux ecosystem: iptables/nftables (micro-segmentation), PAM (authentication), auditd (auditing), Fail2Ban (automatic blocking), WireGuard (secure tunnel), HashiCorp Vault (secret management). Together these form a comprehensive Zero Trust infrastructure.
Protect your Linux server against malware and rootkits. rkhunter and ClamAV installation, scan configuration, result interpretation, scheduled scans, and incident response guide.
Protect your server against SSH brute-force attacks with Fail2Ban. Installation, jail.local configuration, Nginx/Apache jails, IP whitelisting, ban monitoring, and email alerts.
Set up a WireGuard VPN server: key generation, server and client configuration, IP forwarding, firewall rules, and Windows/Linux/Android client setup guide.