HomeThe Stash

Lab 02 — Bandit 0 to 5: your first shell on someone else’s machine

LabSeptember 13, 2026

BeginnerTime ~45 minTarget OverTheWire BanditLevels 0 → 5Needs a terminal

0 / 6 steps

The goal

By the end of this you will have connected to a remote machine over SSH, moved around a Linux filesystem you have never seen before, and pulled a file out of it that was deliberately made awkward to open. Six levels, each one a single obstacle. No prior terminal experience assumed.

There are no passwords on this page, and that is deliberate. OverTheWire's own rules ask content creators not to publish game credentials, and they are right to. A walkthrough that hands you the answers teaches you to copy, not to look — and their passwords rotate anyway, so anything printed here would be wrong within months. What you get instead is the reasoning and the exact commands. You find the passwords yourself, which was the entire point of going there.

Bandit is run by the OverTheWire community, free, on donated infrastructure. This walkthrough is mine; the wargame is theirs, and it is worth your respect and their bandwidth.

Before you start. You need a terminal with an SSH client. Linux and macOS have one already — open Terminal. On Windows, PowerShell has had SSH built in for years, so it works too, though the Kali VM from Lab 00 is a more comfortable home for this kind of work. Nothing gets installed on your machine and nothing runs locally: everything here happens on a server somebody else maintains.

Open a notes file before you type anything. Bandit does not save your progress. Each level gives you the password for the next one, and if you close the terminal without writing it down you start again from zero. A plain text file next to you, one line per level, is all it takes. This is also the habit that separates people who finish wargames from people who abandon them.

Steps

01Get in

Level 0 asks one thing: log in. The credentials for this first level are published on OverTheWire's own site as the front door — username bandit0, password bandit0. Everything after this you find yourself.

$ ssh bandit0@bandit.labs.overthewire.org -p 2220
the first time, you get asked about a fingerprint

The authenticity of host '[bandit.labs.overthewire.org]:2220 ...' can't be established.
ED25519 key fingerprint is SHA256:...
Are you sure you want to continue connecting (yes/no/[fingerprint])?

Read the command left to right. ssh is the client. bandit0@ is who you are logging in as. Then the hostname. Then -p 2220, which matters more than it looks — SSH normally listens on port 22, and leaving that flag off is the single most common reason this first step fails for people. If you get connection refused, that is almost always what happened.

About that fingerprint prompt. Your machine has never spoken to this server before, so it is showing you the server's public key and asking whether you trust it. Type yes. In a real engagement you would verify that fingerprint against a value you were given out of band, because accepting blindly is exactly how a machine-in-the-middle succeeds. Here the risk is nil, but notice that the prompt is a security decision and not a formality.

Your password will not appear as you type it. No dots, no asterisks, nothing. The terminal is not frozen and your keyboard is not broken. Type it and press enter.

02Look around, then read a file

Level 0 to 1 is the gentlest one in the game: the next password sits in a file named readme in your home directory. Two commands do it.

$ ls -la
then read what you found

$ cat readme

Why -la and not bare ls. The -l gives you the long form: permissions, owner, group, size, modification date. The -a includes entries beginning with a dot, which Unix hides by convention. Get into the habit now — you will need -a in step 05, and the owner and size columns from -l are what levels 6 and 7 are built around.

Write the password down before you do anything else. Then log out with exit and come back in as bandit1. Every level works this way: the password you find is the login for the next user, on the same host and the same port.

03A file named after a flag

The next file is called -. Just a hyphen. Try the obvious thing first, because the way it fails is the lesson.

$ cat ./-
run a bare  cat -  first and watch it sit there doing nothing.
press Ctrl-C to get out, then run the command above.

What just happened. A bare - is a long-standing Unix convention meaning standard input rather than a filename. So cat - does exactly what you asked: it waits for you to type something. It is not hung, it is listening.

The fix, and why it generalises. ./ means “in the current directory”. Putting it in front turns the argument into an unambiguous path, and a path is never mistaken for a flag. The same trick saves you whenever a filename starts with a hyphen — which, notably, is also how a certain class of command-injection bug gets started when a program builds a command line out of filenames it did not choose.

04Spaces in the filename

This one is called --spaces in this filename--. Two problems at once: it opens with hyphens, and it contains spaces, which the shell treats as the boundary between one argument and the next.

$ cat "./--spaces in this filename--"
or let the shell do the typing for you

$ cat ./--spa<TAB>

Two fixes, both worth knowing. Quoting the whole thing tells the shell to treat it as one argument, spaces and all. Backslash-escaping each space does the same job more painfully. And tab completion does it for you: type the first few characters and press Tab, and the shell fills in the rest correctly escaped. Use Tab constantly — it is faster and it does not make typos.

The real lesson is about the shell, not the file. Nothing here is a trick. The shell splits your line into words before the command ever sees it, and every one of these levels is really asking whether you understand that. Once you do, quoting stops being something you memorise.

05A hidden file

Now there is a directory called inhere, and the file you want inside it is hidden. You already have the flag for this from step 02.

$ cd inhere && ls -la

“Hidden” is a convention, not a permission. A file whose name starts with a dot is omitted by ls and by shell globbing, and that is the entire mechanism. It is not encrypted, not protected, not access-controlled. Anyone who types ls -a sees it.

Why this matters beyond the game. Dotfiles are where configuration and credentials live — .ssh, .aws, .git, .env. Somebody who thinks a leading dot is security is one ls -a away from finding out otherwise, and on a real host that is frequently where the interesting things are.

06One readable file among many

The last level in this run puts a pile of files in inhere and tells you only one of them is human-readable. Resist the urge to cat them one at a time — several are binary, and dumping binary to a terminal will scramble it.

$ file ./*
one of these is not like the others

./-file00: data
./-file01: data
./-file07: ASCII text
...

file reads the contents, not the name. It looks at the opening bytes and matches them against a database of known signatures. That is why it can tell you something is a PNG when it has been renamed to .txt, and it is the same reasoning behind a good deal of malware triage. Extensions are a suggestion; magic bytes are evidence.

If your terminal does get scrambled — garbage characters, wrong colours, keyboard producing nonsense — type reset and press enter. It will look like nothing is happening as you type. It usually works anyway.

Note the ./ again. The filenames here start with hyphens too. Step 03 was not a one-off; it was preparation.

Lab complete

You have logged into a remote host, listed and read files whose names actively fight the shell, found something hidden, and identified a file by its contents rather than its name. That is a working baseline for everything that follows.

Before you leave — prove it

Without scrolling up: one, why does cat - appear to hang? Two, name two different ways to open a file with spaces in its name. Three, what does file look at that ls does not?

If all three come without effort, the next five levels will feel like a natural continuation rather than a step up.

What you learned

  • ssh user@host -p port — connecting, and why the port flag is not optional
  • Host key fingerprints — a trust decision disguised as a yes/no prompt
  • ls -la — permissions, owner, size and the hidden entries, all in one
  • ./ before a filename — how to stop the shell reading a file as a flag
  • Quoting and tab completion — because the shell splits on spaces before your command ever runs
  • file — identifying contents rather than trusting an extension

NextLab 03 — Bandit 5 to 10: finding things you cannot see

Go deeper

  • OverTheWire Bandit — the wargame itself, free and community-run
  • OverTheWire's rules — short, sensible, and worth reading before you write anything up yourself
  • Lab 00 if you want a Kali VM to do this from, and Lab 01 for your first nmap scan

Original walkthrough. The wargame belongs to the OverTheWire community and this page reproduces none of their level text and none of their passwords, in line with their rules for content creators. Commands were checked against their documented behaviour — but Bandit changes, so if a step here no longer matches what your terminal does, tell me and I will fix it.