Why: Reduce attack surface.
Command:
sudo systemctl list-units --type=service --state=running sudo systemctl disable bluetooth.service sudo systemctl stop bluetooth.service
Best Practices:
Disable root login
Use key-based authentication
Change default port
Practical Steps:Edit /etc/ssh/sshd_config:
/etc/ssh/sshd_config
Port 2222 PermitRootLogin no PasswordAuthentication no
sudo systemctl restart sshd
Use UFW (Ubuntu/Debian):
sudo ufw default deny incoming sudo ufw default allow outgoing sudo ufw allow 2222/tcp sudo ufw enable
Use firewalld (RedHat/CentOS/Fedora):
sudo firewall-cmd --permanent --add-port=2222/tcp sudo firewall-cmd --reload
Debian/Ubuntu:
sudo apt install unattended-upgrades sudo dpkg-reconfigure --priority=low unattended-upgrades
RedHat-based:
sudo yum install dnf-automatic sudo systemctl enable --now dnf-automatic.timer
Install and configure auditd:
auditd
sudo apt install auditd audispd-plugins sudo systemctl enable auditd
Example Audit Rule:Track access to /etc/shadow:
/etc/shadow
sudo auditctl -w /etc/shadow -p wa
Tool: AIDE (Advanced Intrusion Detection Environment)
sudo apt install aide sudo aideinit sudo cp /var/lib/aide/aide.db.new /var/lib/aide/aide.db sudo aide --check
Audit users:
cut -d: -f1 /etc/passwd
Lock inactive accounts:
sudo usermod -L olduser
/etc/sudoers
sudo
Example:
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1 sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
Example: /etc/shadow should be:
sudo chmod 000 /etc/shadow sudo chown root:shadow /etc/shadow
Fail2Ban: Protect from brute force
sudo apt install fail2ban sudo systemctl enable fail2ban
Group Policy Path:Computer Configuration → Windows Settings → Security Settings → Account Policies → Password Policy
Computer Configuration → Windows Settings → Security Settings → Account Policies → Password Policy
Enforce password history: 24
Minimum password length: 14
Maximum password age: 60
Lockout duration: 15 minutes
Use PowerShell:
Get-Service | Where-Object {$_.Status -eq 'Running'} Stop-Service -Name 'Fax' -Force Set-Service -Name 'Fax' -StartupType Disabled
New-NetFirewallRule -DisplayName "Allow RDP" -Direction Inbound -Protocol TCP -LocalPort 3389 -Action Allow
Use Group Policy or run:
manage-bde -on C: -RecoveryPassword
Enable Audit Policies:Group Policy → Security Settings → Advanced Audit Policy Configuration
Security Settings → Advanced Audit Policy Configuration
Audit Logon Events
Audit Object Access
Audit Privilege Use
Review logs using Event Viewer
Disable-WindowsOptionalFeature -Online -FeatureName "SMB1Protocol"
Enable NLA (Network Level Authentication)
Limit RDP users to a secure group
Use Duo 2FA or Remote Desktop Gateway
Restrict via IP (firewall rule or VPN)
Use Group Policy to restrict:
Access to cmd, powershell, registry tools
cmd
powershell
Disable local admin accounts
Configure User Rights Assignment:
Deny logon locally: Guests, unused accounts
Guests
Logon as a service: only specific service accounts
Configure real-time protection, cloud-delivered protection, tamper protection.
Use the CIS-CAT tool to scan your Windows server:https://www.cisecurity.org/cis-cat-lite
Apply recommendations incrementally.