Why and what · wrap-up
Cheat sheet & self-check
Every command from this section on one page.
The CIA triad
Confidentiality | Only the right people can read it (encryption, access control) |
Integrity | Nobody can change it unnoticed (hashes, signatures, permissions) |
Availability | It works when needed (backups, redundancy, DDoS protection) |
Principles
Defence in depth | Several independent layers, so one failure is not a breach |
Least privilege | Every user and program gets only the access it needs |
Small attack surface | Fewer open ports, services, packages and accounts |
Secure by default | The default setting is the safe one |
Assume breach | Plan detection and recovery, not only prevention |
Look at your own exposure
sudo ss -tulpn | Which programs are listening on which ports |
sudo journalctl -u ssh --since today | grep -c 'Failed password' | How many SSH password guesses today |
last -n 20 | Recent logins |
Risk words
Asset | Something of value: data, a server, a reputation |
Threat | Who or what could cause harm: a criminal group, a careless admin, a flood |
Vulnerability | A weakness that could be used: a bug, a weak password, an open port |
Exploit | A method or code that uses a vulnerability |
Risk | Likelihood × impact of a threat using a vulnerability against an asset |
Zero-day | A vulnerability attackers use before a fix exists |
CVE | A public ID for a known vulnerability, e.g. CVE-2024-6387 |
CVSS | A 0–10 severity score for a vulnerability |
The three As
Authentication (authN) | Proving who you are: password, key, certificate, MFA |
Authorisation (authZ) | What you are allowed to do once known |
Accounting / auditing | Recording who did what, and when |
Encoding, encryption, hashing
echo -n 'hello' | base64 | Encoding: reversible by anyone, no secret involved |
openssl enc -aes-256-cbc -pbkdf2 -in f -out f.enc | Encryption: reversible only with the key |
echo -n 'hello' | sha256sum | Hashing: one-way fingerprint, cannot be reversed |
Building blocks
Symmetric encryption (AES, ChaCha20) | One shared key locks and unlocks; very fast; used for the actual data |
Asymmetric key pair (RSA, ECDSA, Ed25519) | Public key can be shared; private key never leaves its owner |
Key exchange (Diffie-Hellman, ECDHE) | Two sides agree a shared secret over a public network |
Hash (SHA-256) | Fixed-size fingerprint of any data; any change gives a different hash |
Digital signature | Hash of the data, signed with a private key; anyone with the public key can verify |
Try them
openssl genpkey -algorithm ed25519 -out priv.pem | Make a private key |
openssl pkey -in priv.pem -pubout -out pub.pem | Derive its public key |
openssl pkeyutl -sign -inkey priv.pem -rawin -in msg.txt -out msg.sig | Sign a file |
openssl pkeyutl -verify -pubin -inkey pub.pem -rawin -in msg.txt -sigfile msg.sig | Verify the signature |
sha256sum file.iso | Check a download against its published hash |