Cybersecurity: OpenSSL, Firewalls, Nmap & Hardening
Your pocket reference for locking down Linux servers, verifying TLS certificates, auditing open ports, and choosing modern encryption without locking yourself out.
If one security layer fails, the next layer stops the attacker. Never rely on a single lock.
1 Firewall Commands (UFW, iptables, firewalld)
A firewall is your server's bouncer: it checks every incoming packet against a rule list before letting it reach an app. Beginners usually start with UFW (Ubuntu/Debian) or firewalld (RHEL/Alma/Fedora), both of which sit on top of Linux kernel filtering.
UFW (Ubuntu / Debian)
sudo ufw status verbose
sudo ufw allow 22/tcp
sudo ufw allow 443/tcp
sudo ufw deny from 203.0.113.50
sudo ufw enable
iptables & firewalld (Low-Level & RHEL/Fedora)
sudo iptables -L -n -v
-n, fast) and packet counters (-v).sudo firewall-cmd --list-all
sudo firewall-cmd --permanent --add-service=https && sudo firewall-cmd --reload
--reload.Think of UFW like locking a house from the inside: make sure you have your key (ufw allow 22/tcp) before you slam the deadbolt (ufw enable).
2 OpenSSL & Hashing Quick Commands
OpenSSL is the Swiss Army knife for TLS certificates and encryption, while hashing creates a unique digital fingerprint of a file so you can prove it wasn't tampered with.
openssl s_client -connect example.com:443 -servername example.com
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes
-nodes skips passphrase).sha256sum installer.iso
ssh-keygen -t ed25519 -C "work-laptop"
openssl rand -base64 32
Encryption (AES, TLS) is a locked box—you can unlock it with the key. Hashing (SHA-256) is a blender—you can't turn the smoothie back into fruit, only check if two smoothies match.
3 Network Auditing & Port Inspection
nmap against systems you own or have explicit written permission to test. Scanning third-party networks without authorization may violate laws and terms of service.
nmap -sV -sC 192.168.56.10
-sV), and runs safe default checks (-sC).ss -tulpn
t) & UDP (u) listening (l) socket with numeric ports (n) and process IDs (p).sudo fail2ban-client status sshd
Common Ports to Watch
22/TCP SSH 53/UDP+TCP DNS 80/TCP HTTP 443/TCP HTTPS 3306/TCP MySQL 5432/TCP PostgreSQL
4 Encryption & Security Protocols Quick Table
Use this cheat table to pick the right cryptographic standard for data at rest, data in transit, passwords, Wi-Fi, and user logins.
| Protocol / Standard | Type | Status (2026) | When to Use & Why |
|---|---|---|---|
| AES-256-GCM | Symmetric Encryption | Recommended | Encrypting files, disks (LUKS), and databases. Same key locks & unlocks; GCM also verifies integrity. |
| ECC (Ed25519 / X25519) vs RSA-4096 | Asymmetric (Public/Private) | ECC Preferred | SSH keys & TLS handshakes. ECC gives equal security to RSA-3072/4096 with tiny, fast keys. |
| Argon2id vs SHA-256 | Password Hashing vs File Integrity | Role-Specific | Argon2id for passwords (slow + memory-hard stops GPUs). SHA-256 for file checksums (fast). |
| TLS 1.3 | Transport Security | Required | Secures HTTPS traffic. Faster 1-RTT handshake and removes weak legacy ciphers (disable TLS 1.0/1.1). |
| WPA3-Personal / Enterprise | Wi-Fi Security | Recommended | Replaces WPA2; uses SAE handshake to block offline dictionary cracking of your Wi-Fi password. |
| MFA (FIDO2 / TOTP) | Authentication Factors | Essential | Combines Something you know (password) + have (hardware key / authenticator app) + are (biometric). |
5 Danger Zone & Quick Hardening
ufw enable before ufw allow 22/tcp
UFW blocks all incoming traffic by default. If you enable it on a cloud VM without allowing SSH first, your terminal drops immediately and you are locked out.
MD5 and SHA-1 are cryptographically broken, and plain SHA-256 is too fast—modern GPUs can guess billions of passwords per second. Always use Argon2id or bcrypt with a salt.
PermitRootLogin yes in /etc/ssh/sshd_config
Botnets hammer the root username 24/7. Set PermitRootLogin no and PasswordAuthentication no after testing your Ed25519 SSH key.
sudo ufw allow 22/tcp # 1. Keep SSH open first sudo ufw allow 443/tcp # 2. Allow HTTPS if hosting web apps sudo ufw --force enable # 3. Turn on firewall safely sudo apt update && sudo apt install -y fail2ban sudo ss -tulpn # 4. Verify only expected ports listen