Courses3 levels
Level 1 · Foundations11 courses
Level 2 · Core5 courses
Level 3 · Advanced5 courses
Labs8 topics
Library Practice exams AI Range Pricing Start free

Set-up · 15 minutes

Set up your lab for Cloud security basics

After this lesson you can
  • Create the lab folder of the course
  • Understand how you can learn cloud security with no cloud account
  • Prove with a check script that the lab is ready
Lab files of this lesson (1)

The lab folder as it stands after this lesson. Unzip it in ~/krlab.

More

The zip holds every file that the course has printed up to here. Type the code yourself first: you learn more.

What you need

  • The five courses that come before this one. This course uses what they teach and does not teach it again. From "Linux" (Part 1) you need lessons 4 and 6 (search text, join commands with pipes) and lesson 10 (permissions). From "Networking hands-on" you need lessons 2 and 5 (addresses, routes and ports), lessons 8 and 9 (HTTP and TLS) and lessons 11 and 12 (firewalls). From "Python for security work" you need lessons 2 to 6: collections, functions, files and JSON, command-line tools and HTTP. From "Security fundamentals" you need lessons 3 to 6: authentication, least privilege, cryptography with OpenSSL, and logging. From "Security operations basics" you need lessons 1 to 4 (read logs, make events, write rules, triage) and lessons 11 to 13 (the incident response lifecycle, containment and evidence, the report).
  • Python 3.12 or later. Every program of this course uses the standard library only, so you install no package and you need no virtual environment.
  • A Linux terminal, or WSL (Windows Subsystem for Linux) on Windows, with openssl, curl and sha256sum. You used all three in the earlier courses. No sudo. About 20 MB of disk.
  • No cloud account, no payment and no network. You never sign in to a cloud provider in this course, and no lesson sends a request to one.
  • One folder for everything. The page of the course offers a zip with the lab files of each lesson, in a folder for each lesson. The programs of later lessons import the programs of earlier lessons, so they must all be in one folder. Unzip it into a new folder with python3 -m zipfile -e files.zip lab (or unzip files.zip), go into the folder that it makes with cd lab/cloud-security-basics (it holds one folder for each lesson, and kr-lab.sh), and run sh kr-lab.sh LESSON ~/krlab/cloud-security-basics. That builds the lab folder as it stands after a lesson (LESSON is the name of a lesson folder in the zip, for example 03-find-policies-that-give-too-much). kr-lab.sh overwrites files that have the same name: keep your own programs in another folder. Or type the files from the lessons.

A cloud provider rents out computers, storage and networks that you control through a web interface, with no hardware of your own. Most companies now keep at least part of their systems with one. This course teaches you to find the mistakes that expose such systems: access rules that are too wide, keys in the wrong place, storage that the whole internet can read, open network ports, and logs that are switched off.

How can you learn this with no account? A cloud account is described by its configuration, and the configuration is text: policy documents, rule lists and log records, almost all of it JSON. A defender reads that text far more often than they click in a console. So each lesson gives you a snapshot: files that describe the account of an invented company, made by a generator program with a fixed seed. You write small Python tools that read the snapshot and decide what is wrong. In a real account you would make the snapshot with the AWS CLI, a command-line program named aws: aws iam update-access-key sends the API call UpdateAccessKey to the IAM service, and file://NAME reads an option value from a local file. The cheat sheet lists the calls, and this course does not run them. Where a service must answer (lesson 8), you start a small stand-in on your own machine, on 127.0.0.1, port 8700.

One provider, in depth. The course teaches the model of Amazon Web Services (AWS), the provider that job postings name most often. Each topic ends with a short table, "Same idea, other names", for Microsoft Azure and Google Cloud. The statements about AWS were checked against the AWS documentation in November 2026. Cloud services change: before you rely on a default or a limit at work, read the current text of the provider.

What is real and what is ours. Policy documents and audit-log records in the snapshot have the real field names of AWS, so that what you learn carries over. The inventory, the bucket list and the network file use a simple shape of our own, and each lesson says so. Everything in the files is invented. The account numbers are the ones that the AWS documentation uses in its own examples (111122223333, 444455556666, 123456789012). The addresses come from the three ranges that are reserved for documentation (192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24). Every key ends in EXAMPLE, as the keys in the AWS documentation do, and opens nothing.

The data is fixed. A generator with a fixed seed writes the same files on every machine (the course "Security operations basics" explains seeds in its set-up lesson), and it prints a short hash of each file so that you can compare.

Set it up

1. Make the lab folder

mkdir -p ~/krlab/cloud-security-basics
cd ~/krlab/cloud-security-basics
pwd
/home/you/krlab/cloud-security-basics

Every lesson works in this one folder. The generator of lesson 1 puts the snapshot in a subfolder named account, and the programs that you write stay next to it.

2. Look at your tools

python3 --version prints the version of Python. which prints the path of a program, or nothing if it is missing.

python3 --version
which openssl curl sha256sum
Python 3.14.4
/usr/bin/openssl
/usr/bin/curl
/usr/bin/sha256sum

Your version and your paths may differ. The version must be 3.12 or later.

Check your lab

The script labcheck.py checks seven things and prints one line for each: the Python version, the folder, the tools, a fixed seed, a fixed hash, the right to write in the folder, and that port 8700 is free. You know most of its parts from the set-up of "Security operations basics". New here: socket.socket().bind(("127.0.0.1", 8700)) asks the system for port 8700 on your own machine, and it fails when another program holds that port.

labcheck.py

"""labcheck.py: prove that the lab of "Cloud security basics" works. Standard library only."""
import hashlib
import random
import shutil
import socket
import sys
from pathlib import Path

results = []


def line(name, ok, detail):
    """Print one line for one requirement and remember the result."""
    results.append(ok)
    print(("ok   " if ok else "FAIL ") + name.ljust(8) + detail)


v = sys.version_info
line("python", v >= (3, 12), f"{v.major}.{v.minor}.{v.micro}")

folder = Path.home() / "krlab" / "cloud-security-basics"
line("folder", folder.is_dir(), str(folder))

missing = [tool for tool in ("openssl", "curl", "sha256sum") if not shutil.which(tool)]
line("tools", not missing, "openssl curl sha256sum found" if not missing else "missing: " + " ".join(missing))

first = round(random.Random(7).random(), 6)
line("seed", first == 0.323833, f"the generator with seed 7 starts with {first}")

digest = hashlib.sha256(b"kalirange").hexdigest()[:12]
line("hash", digest == "344d71bf784c", f"sha256 of the word kalirange starts with {digest}")

try:
    probe = folder / ".probe"
    probe.write_text("x")
    probe.unlink()
    writable = True
except OSError:
    writable = False
line("write", writable, "you can write in the lab folder")

try:
    with socket.socket() as s:
        s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)  # a port that was closed a moment ago counts as free
        s.bind(("127.0.0.1", 8700))
    free = True
except OSError:
    free = False
line("port", free, "port 8700 on 127.0.0.1 is free")

print(f"lab ready: {sum(results)} of {len(results)}")
sys.exit(0 if all(results) else 1)
python3 labcheck.py
ok   python  3.14.4
ok   folder  /home/you/krlab/cloud-security-basics
ok   tools   openssl curl sha256sum found
ok   seed    the generator with seed 7 starts with 0.323833
ok   hash    sha256 of the word kalirange starts with 344d71bf784c
ok   write   you can write in the lab folder
ok   port    port 8700 on 127.0.0.1 is free
lab ready: 7 of 7

Your Python version can differ. The last line must be the same. Type the last line of your own output.

If it fails

Read the first line that starts with FAIL. Fix that one, then run python3 labcheck.py again. The script ends with exit code 1 when a requirement fails.

The script saysWhat it meansWhat to do
FAIL pythonPython is older than 3.12.Install Python 3.12 or later and run the script with that python3.
FAIL folderThe folder does not exist, or you made it in another place.Run mkdir -p ~/krlab/cloud-security-basics again. The script looks in your home folder.
FAIL toolsA tool is missing.Install it with the package manager of your system. On macOS, sha256sum comes with GNU coreutils.
FAIL seedYour Python gives other numbers for the seed 7.This should not happen. Update Python, and run the script again.
FAIL writeYou cannot write in the folder.Check the owner and the permissions of ~/krlab (Linux Part 1, lesson 10).
FAIL portAnother program uses port 8700.Stop that program. Or use another free port in lesson 8: the mock service takes the port as its second argument, and you change 8700 in every command of that lesson.