Security Basics — SSH, TLS and Certificates›Why and what · Cheat sheet & self-check

Why and what · wrap-up

Cheat sheet & self-check

Every command from this section on one page.

01 · Why security matters

The CIA triad

ConfidentialityOnly the right people can read it (encryption, access control)
IntegrityNobody can change it unnoticed (hashes, signatures, permissions)
AvailabilityIt works when needed (backups, redundancy, DDoS protection)

Principles

Defence in depthSeveral independent layers, so one failure is not a breach
Least privilegeEvery user and program gets only the access it needs
Small attack surfaceFewer open ports, services, packages and accounts
Secure by defaultThe default setting is the safe one
Assume breachPlan detection and recovery, not only prevention

Look at your own exposure

sudo ss -tulpnWhich programs are listening on which ports
sudo journalctl -u ssh --since today | grep -c 'Failed password'How many SSH password guesses today
last -n 20Recent logins

02 · The vocabulary of security

Risk words

AssetSomething of value: data, a server, a reputation
ThreatWho or what could cause harm: a criminal group, a careless admin, a flood
VulnerabilityA weakness that could be used: a bug, a weak password, an open port
ExploitA method or code that uses a vulnerability
RiskLikelihood × impact of a threat using a vulnerability against an asset
Zero-dayA vulnerability attackers use before a fix exists
CVEA public ID for a known vulnerability, e.g. CVE-2024-6387
CVSSA 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 / auditingRecording who did what, and when

Encoding, encryption, hashing

echo -n 'hello' | base64Encoding: reversible by anyone, no secret involved
openssl enc -aes-256-cbc -pbkdf2 -in f -out f.encEncryption: reversible only with the key
echo -n 'hello' | sha256sumHashing: one-way fingerprint, cannot be reversed

03 · Cryptography without the maths

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 signatureHash of the data, signed with a private key; anyone with the public key can verify

Try them

openssl genpkey -algorithm ed25519 -out priv.pemMake a private key
openssl pkey -in priv.pem -pubout -out pub.pemDerive its public key
openssl pkeyutl -sign -inkey priv.pem -rawin -in msg.txt -out msg.sigSign a file
openssl pkeyutl -verify -pubin -inkey pub.pem -rawin -in msg.txt -sigfile msg.sigVerify the signature
sha256sum file.isoCheck a download against its published hash