Cloned Boy
Professional
- Messages
- 877
- Reaction score
- 700
- Points
- 93
Unix-like systems (Linux, macOS, BSD, etc.) are widely used in servers, networking, and security-critical environments due to their robust permission model, open-source transparency, and strong security heritage. Below is a breakdown of core security concepts in *nix systems.
Would you like a deeper dive into a specific area (e.g., SELinux, SSH hardening, or container security)?
1. Fundamental Security Principles
*nix systems follow several key security principles:- Principle of Least Privilege → Users and processes should have only the minimum permissions needed.
- Defense in Depth → Multiple layers of security (firewalls, permissions, encryption).
- No Default Trust → Everything must be authenticated and authorized.
2. Core nix Security Mechanisms
A) User & Permission Model
- Users & Groups
- Every process runs under a user (root = superuser).
- Groups allow permission sharing (e.g., www-data for web servers).
- File Permissions (chmod, chown)
- Read (r), Write (w), Execute (x) for Owner, Group, Others.
- Example: -rwxr-xr-- (Owner: read/write/execute, Group: read/execute, Others: read-only).
- SUID, SGID, Sticky Bits
- SUID → Runs a file as its owner (e.g., passwd runs as root).
- SGID → Runs a file with group privileges.
- Sticky Bit → Only owner can delete/modify files in a directory (e.g., /tmp).
B) Access Control Lists (ACLs)
- Extends traditional permissions for finer control.
- Example:
sh
Code:setfacl -m u:alice:rwx /shared_folder # Grants Alice full access getfacl /shared_folder # Shows ACL permissions
C) Mandatory Access Control (MAC) Systems
- SELinux (Security-Enhanced Linux)
- Enforces strict policies (e.g., a web server can’t access /home).
- AppArmor
- Profile-based restrictions (e.g., only allow /usr/bin/nginx to read /var/www).
D) Process Isolation & Sandboxing
- Namespaces → Isolates processes (filesystem, network, PID).
- cgroups → Limits resource usage (CPU, memory).
- Containers (Docker, LXC) → Combines namespaces + cgroups for lightweight virtualization.
E) Secure Authentication
- Shadow Passwords (/etc/shadow) → Hashed passwords (SHA-512, bcrypt).
- SSH Key Authentication → Uses RSA/ECDSA keys instead of passwords.
- PAM (Pluggable Authentication Modules) → Flexible auth policies (2FA, LDAP).
F) Logging & Auditing
- syslog / journalctl (systemd) → System logs.
- auditd → Tracks file access, system calls (for compliance).
- fail2ban → Blocks brute-force attacks (SSH, FTP).
3. Common nix Security Tools
Tool | Purpose |
---|---|
iptables/nftables | Firewall (packet filtering, NAT). |
OpenSSH | Secure remote access (replace Telnet/FTP). |
GPG | File & email encryption. |
ClamAV | Malware scanning. |
Tripwire/AIDE | File integrity monitoring (detect unauthorized changes). |
SELinux/AppArmor | Mandatory access control. |
Lynis | Security auditing tool. |
4. Best Practices for nix Security]
- Minimal Installation → Only install necessary services.
- Regular Updates → Patch OS and software (apt update && apt upgrade).
- Disable Root SSH Login → Use sudo instead.
- Firewall Rules → Block unnecessary ports (iptables -A INPUT -p tcp --dport 22 -j ACCEPT).
- Disable Unused Services → Stop telnet, ftp, rlogin.
- Use SSH Keys + 2FA → Disable password-based SSH.
- Encrypt Sensitive Data → Use LUKS (disk encryption) or GPG (files).
- Monitor Logs → Check /var/log/auth.log, journalctl -u sshd.
5. Attack Vectors & Mitigations
Attack | Defense |
---|---|
Brute-Force SSH | Fail2ban, key-based auth, rate limiting. |
Privilege Escalation | SELinux, minimal sudo access, regular audits. |
Malware/Rootkits | ClamAV, rkhunter, signed packages. |
Misconfigured Services | Lynis, hardening guides (CIS benchmarks). |
Unencrypted Data | Full-disk encryption (LUKS), HTTPS, VPNs. |
Final Thoughts
*nix systems are inherently secure but require proper configuration. Key takeaways:- Principle of Least Privilege → Limit root access.
- Hardening → Firewalls, MAC (SELinux/AppArmor), encryption.
- Monitoring → Logs, intrusion detection (AIDE, auditd).
Would you like a deeper dive into a specific area (e.g., SELinux, SSH hardening, or container security)?