-
-
Notifications
You must be signed in to change notification settings - Fork 1
CachyOS Security Configuration
Complete beginner-friendly guide to securing your CachyOS system, including firewall, user management, encryption, and security best practices.
- Understanding Linux Security
- Firewall Configuration
- User Management
- File Permissions
- Encryption
- SSH Security
- System Updates
- Security Best Practices
Linux security is based on several principles:
- Least privilege: Users have minimum necessary access
- Defense in depth: Multiple security layers
- Regular updates: Keep system updated
- Strong passwords: Use secure passwords
- Access control: Control who can access what
Multiple layers:
- Firewall: Network security
- User permissions: File access control
- Encryption: Data protection
- Updates: Security patches
- Monitoring: Detect issues
Firewall controls network traffic to/from your system.
Why it matters:
- Blocks attacks: Prevents unauthorized access
- Controls traffic: Allows/denies connections
- Protects services: Secures network services
Install firewalld:
sudo pacman -S firewalldStart firewalld:
sudo systemctl enable --now firewalldCheck status:
sudo firewall-cmd --stateWhat this does:
- Shows firewall status
-
running: Firewall is active -
not running: Firewall is off
List active zones:
sudo firewall-cmd --get-active-zonesWhat this does:
- Shows active firewall zones
- Shows which interfaces are in zones
List allowed services:
sudo firewall-cmd --list-servicesWhat this does:
- Shows allowed services
- Shows what's permitted
Allow service:
sudo firewall-cmd --add-service=http --permanent
sudo firewall-cmd --reloadWhat this does:
- Allows HTTP service
-
--permanent: Makes change permanent -
--reload: Applies changes
Block port:
sudo firewall-cmd --add-port=8080/tcp --permanent
sudo firewall-cmd --reloadWhat this does:
- Allows port 8080
-
tcp: TCP protocol - Can also use
udp
Create user:
sudo useradd -m -G wheel usernameWhat this does:
-
-m: Creates home directory -
-G wheel: Adds to wheel group (sudo access) - Creates new user
Set password:
sudo passwd usernameWhat this does:
- Sets user password
- Prompts for password
- Secures user account
Delete user:
sudo userdel -r usernameWhat this does:
-
-r: Removes home directory - Deletes user account
- ** Permanent action**
Edit sudoers:
sudo visudoWhat this does:
- Opens sudo configuration
- Safe editing (validates syntax)
- ** Edit carefully**
Allow user sudo:
username ALL=(ALL) ALL
What this does:
- Allows user full sudo access
- Can run any command as root
- Add to sudoers file
Restrict sudo:
username ALL=(ALL) NOPASSWD: /usr/bin/pacman
What this does:
- Allows specific command only
- No password required
- More restrictive
File permissions control who can access files.
Permission types:
- Read (r): Can view file
- Write (w): Can modify file
- Execute (x): Can run file
Permission groups:
- Owner: File owner
- Group: File group
- Others: Everyone else
View permissions:
ls -l file.txtWhat this shows:
-rw-r--r-- 1 user group 1024 Jan 1 12:00 file.txt
What this means:
-
-rw-r--r--: Permissions -
user: Owner -
group: Group -
1024: Size
Change permissions:
chmod 644 file.txtWhat this does:
- Sets permissions to 644
- Owner: read+write
- Group: read
- Others: read
Permission numbers:
- 4: Read
- 2: Write
- 1: Execute
- 7: All (4+2+1)
Change owner:
sudo chown user:group file.txtWhat this does:
- Changes file owner
- Changes file group
- Requires sudo
Full disk encryption protects all data.
During installation:
- Enable encryption in installer
- Set encryption password
- Protects entire system
LUKS encryption:
- Linux Unified Key Setup
- Standard disk encryption
- Strong encryption
Encrypt files with GPG:
gpg -c file.txtWhat this does:
- Encrypts file
- Creates
file.txt.gpg - Requires password
Decrypt file:
gpg -d file.txt.gpg > file.txtWhat this does:
- Decrypts file
- Requires password
- Outputs to file
Install GPG:
sudo pacman -S gnupgEdit SSH config:
sudo nano /etc/ssh/sshd_configSecurity settings:
PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes
What this does:
-
PermitRootLogin no: Disables root login -
PasswordAuthentication no: Disables password auth -
PubkeyAuthentication yes: Enables key auth
Restart SSH:
sudo systemctl restart sshdWhat this does:
- Applies SSH configuration
- Restarts SSH service
- Changes take effect
Generate SSH key:
ssh-keygen -t ed25519What this does:
- Creates SSH key pair
-
-t ed25519: Key type - More secure than RSA
Copy public key:
ssh-copy-id user@serverWhat this does:
- Copies public key to server
- Enables key-based login
- More secure than passwords
Update system:
sudo pacman -SyuWhat this does:
- Updates all packages
- Includes security updates
- Keeps system secure
Check for updates:
pacman -QuWhat this does:
- Lists available updates
- Shows what needs updating
- Check regularly
Enable automatic updates (optional):
# Create update script
sudo nano /usr/local/bin/auto-update.shAdd:
#!/bin/bash
pacman -Syu --noconfirmSchedule with systemd:
sudo systemctl enable --now update.timer** Automatic updates can be risky!**
Strong passwords:
- Length: At least 12 characters
- Complexity: Mix of letters, numbers, symbols
- Uniqueness: Different for each account
- No dictionary words: Avoid common words
Password manager:
- Use password manager
- Generate strong passwords
- Store securely
Backup regularly:
- Protects against data loss
- Enables recovery
- Important for security
Check logs:
journalctl -p errWhat this does:
- Shows error logs
- Helps detect issues
- Monitor regularly
Check failed logins:
sudo lastbWhat this does:
- Shows failed login attempts
- Helps detect attacks
- Monitor for suspicious activity
- CachyOS System Maintenance - System maintenance
- CachyOS Backup and Restore - Backup procedures
- Arch Linux Wiki - Security: https://wiki.archlinux.org/title/Security
- Arch Linux Wiki - Firewalls: https://wiki.archlinux.org/title/Firewalls
This guide covered:
- Understanding Linux security - Security principles
- Firewall configuration - Network security
- User management - User accounts and sudo
- File permissions - Access control
- Encryption - Data protection
- SSH security - Remote access security
- System updates - Security patches
- Best practices - Security recommendations
Key Takeaways:
- Use firewall to protect network
- Create users with appropriate permissions
- Set strong passwords
- Encrypt sensitive data
- Keep system updated
- Monitor logs for issues
- Follow security best practices
- Regular backups are important
This guide is based on the CachyOS Wiki and Arch Linux Wiki and expanded with detailed explanations for beginners. For the most up-to-date security information, always refer to the official documentation.