ABDURROZAK.MY.ID // DEBIAN LINUX SERVER FUNDAMENTAL
LINUX SERVERSECURITY
Volume 15 dari seri Debian Linux Server Fundamental. Panduan komprehensif dasar keamanan Debian Server. Setiap command dan script dijelaskan detail dengan penjelasan per baris. Dari update security, firewall, UFW/nftables, SSH hardening, user security, permission security, Fail2ban, hingga basic server hardening.
VOLUME15 / 17
SUB-BAB8
BACA90 MENIT
SECURITY100%
ABDUR ROZAK, S.Kom.
Web Developer & Network Educator - abdurrozak.my.id
VOLUME 15 / 17
DASAR KEAMANAN DEBIAN SERVER
Panduan lengkap Linux Server Security di Debian Linux. 8 sub-bab mencakup update security, firewall, UFW atau nftables, SSH hardening, user security, permission security, Fail2ban, hingga basic server hardening. Setiap command dan script disertai penjelasan detail per baris.
SUB-BAB8LEVELSecurityWAKTU90 MENIT
01
SUB-BAB 01 UPDATE
UPDATE SECURITY
Update Package
UPDATE
# Update package listsudo apt update# Upgrade packagesudo apt upgrade# Upgrade package dengan auto-confirmsudo apt upgrade -y# Full upgrade (upgrade dengan dependency changes)sudo apt full-upgrade -y# Dist-upgrade (upgrade dengan dependency changes dan remove obsolete)sudo apt dist-upgrade -y# Auto-remove obsolete packagessudo apt autoremove -y# Auto-clean cached packagessudo apt autoclean# Clean all cached packagessudo apt clean
Firewall adalah sistem keamanan jaringan yang memonitor dan mengontrol traffic jaringan berdasarkan aturan keamanan yang telah ditentukan. Firewall dapat berupa hardware, software, atau kombinasi keduanya.
Jenis Firewall
JENIS
DESKRIPSI
CONTOH
Packet Filter
Filter berdasarkan header packet
iptables, nftables
Stateful
Filter berdasarkan state koneksi
iptables, nftables
Application
Filter berdasarkan aplikasi
WAF, proxy
Hardware
Hardware dedicated
Fortinet, Cisco ASA
Firewall Actions
ACTION
DESKRIPSI
ACCEPT
Terima packet
DROP
Tolak packet (tidak ada response)
REJECT
Tolak packet (dengan response)
LOG
Log packet
RETURN
Kembali ke chain sebelumnya
KOMPETENSI SUB-BAB 02
Memahami konsep firewall
Memahami jenis firewall
Memahami firewall actions
03
SUB-BAB 03 UFW/NFTABLES
UFW ATAU NFTABLES
UFW (Uncomplicated Firewall)
UFW
# Install UFWsudo apt install ufw# Reset UFWsudo ufw reset# Set default policiessudo ufw default deny incomingsudo ufw default allow outgoing# Allow SSHsudo ufw allow sshsudo ufw allow 22/tcp# Allow HTTPsudo ufw allow httpsudo ufw allow 80/tcp# Allow HTTPSsudo ufw allow httpssudo ufw allow 443/tcp# Allow specific portsudo ufw allow 8080/tcp# Allow specific port with protocolsudo ufw allow 53/udp# Allow from specific IPsudo ufw allow from 192.168.1.100# Allow from specific IP to specific portsudo ufw allow from 192.168.1.100 to any port 22# Allow from specific subnetsudo ufw allow from 192.168.1.0/24# Deny specific portsudo ufw deny 23/tcp# Delete rulesudo ufw delete allow 23/tcp# Delete rule by numbersudo ufw status numberedsudo ufw delete 3# Enable UFWsudo ufw enable# Disable UFWsudo ufw disable# Check statussudo ufw statussudo ufw status verbosesudo ufw status numbered# Reload UFWsudo ufw reload# Reset UFWsudo ufw reset
# Generate SSH key pair (client)ssh-keygen -t ed25519 -C "your_email@example.com"# Generate SSH key pair with RSA (client)ssh-keygen -t rsa -b 4096 -C "your_email@example.com"# Copy public key to serverssh-copy-id user@server-ip# Copy public key manuallycat ~/.ssh/id_ed25519.pub | ssh user@server-ip "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"# Set permissionschmod 700 ~/.sshchmod 600 ~/.ssh/authorized_keys# Test SSH key authenticationssh user@server-ip# Use specific keyssh -i ~/.ssh/id_ed25519 user@server-ip
KOMPETENSI SUB-BAB 04
Mampu hardening SSH configuration
Mampu generate SSH key pair
Mampu copy public key to server
Mampu configure SSH key authentication
05
SUB-BAB 05 USER
USER SECURITY
User Security Best Practices
USER SECURITY
# Create user with no login shellsudo useradd -M -s /sbin/nologin username# Create user with home directorysudo useradd -m username# Set passwordsudo passwd username# Set strong password policysudo apt install libpam-pwqualitysudo nano /etc/security/pwquality.confminlen = 12minclass = 4maxrepeat = 3maxclassrepeat = 4# Lock user accountsudo usermod -L username# Unlock user accountsudo usermod -U username# Delete usersudo userdel username# Delete user with home directorysudo userdel -r username# Add user to groupsudo usermod -aG groupname username# Remove user from groupsudo gpasswd -d username groupname# List user groupsgroups username# List all userscut -d: -f1 /etc/passwd# List all groupscut -d: -f1 /etc/group# Check user password expirysudo chage -l username# Set password expirysudo chage -M 90 username# Set password expiry warningsudo chage -W 7 username
KOMPETENSI SUB-BAB 05
Mampu create user dengan security best practices
Mampu set strong password policy
Mampu lock/unlock user account
Mampu manage user groups
06
SUB-BAB 06 PERMISSION
PERMISSION SECURITY
Permission Security Best Practices
PERMISSION
# Check file permissionsls -la /path/to/file# Set file permissionschmod 644 /path/to/file# Set directory permissionschmod 755 /path/to/directory# Set owner and groupchown user:group /path/to/file# Set owner and group recursivelychown -R user:group /path/to/directory# Set permissions recursivelychmod -R 755 /path/to/directory# Set sticky bitchmod +t /tmp# Set setuid bitchmod u+s /path/to/file# Set setgid bitchmod g+s /path/to/directory# Remove setuid bitchmod u-s /path/to/file# Remove setgid bitchmod g-s /path/to/directory# Find files with setuid bitfind / -perm -4000 -type f 2>/dev/null# Find files with setgid bitfind / -perm -2000 -type f 2>/dev/null# Find world-writable filesfind / -perm -0002 -type f 2>/dev/null# Find world-writable directoriesfind / -perm -0002 -type d 2>/dev/null
Kamu telah menyelesaikan Volume 15 - Linux Server Security. Dari update security, firewall, UFW/nftables, SSH hardening, user security, permission security, Fail2ban, hingga basic server hardening. Kamu sekarang menguasai dasar keamanan Debian Server. Di Volume 16, kita akan dalami Backup & Recovery. Sampai jumpa!