🎩 CentOS/RHEL Server Setup
This guide covers the initial setup for CentOS Stream and RHEL-based distributions (Rocky Linux, AlmaLinux).
System Update
# Update all packages
sudo dnf update -y
# Install essential tools
sudo dnf install -y curl wget git vim htop epel-release
# Enable PowerTools/CRB repo (for additional packages)
sudo dnf config-manager --set-enabled crb # Rocky/Alma 9
# or
sudo dnf config-manager --set-enabled powertools # CentOS Stream 8Create Admin User
# Create user
sudo useradd -m admin
# Set password
sudo passwd admin
# Add to wheel group (sudo)
sudo usermod -aG wheel adminConfigure SSH
# Edit SSH config
sudo vim /etc/ssh/sshd_configRecommended settings:
PermitRootLogin no
PasswordAuthentication no
Port 2222Apply changes:
sudo systemctl restart sshdFirewall (firewalld)
# Start and enable
sudo systemctl enable firewalld
sudo systemctl start firewalld
# Allow SSH (custom port)
sudo firewall-cmd --permanent --add-port=2222/tcp
# Allow HTTP/HTTPS
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
# Reload rules
sudo firewall-cmd --reload
# Check status
sudo firewall-cmd --list-allSELinux Configuration
# Check status
getenforce
# Temporarily set to permissive (for troubleshooting)
sudo setenforce 0
# Edit permanent config
sudo vim /etc/selinux/config
# SELINUX=enforcing (recommended for production)Allow non-standard SSH port:
sudo semanage port -a -t ssh_port_t -p tcp 2222Install Fail2Ban
# Enable EPEL repo
sudo dnf install epel-release
# Install
sudo dnf install fail2ban
# Create local config
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
# Configure
sudo vim /etc/fail2ban/jail.local[sshd]
enabled = true
port = 2222
bantime = 3600
maxretry = 3# Start
sudo systemctl enable fail2ban
sudo systemctl start fail2banAutomatic Updates (dnf-automatic)
# Install
sudo dnf install dnf-automatic
# Configure
sudo vim /etc/dnf/automatic.conf[commands]
apply_updates = yes# Enable timer
sudo systemctl enable --now dnf-automatic.timerDistribution Comparison
| Feature | CentOS Stream | Rocky Linux | AlmaLinux |
|---|---|---|---|
| Base | RHEL | RHEL | RHEL |
| Release | Rolling | Point | Point |
| Support | Community | Community | Community |
Next: Arch Linux Setup