Skip to content
EgyKode
01 · FoundationsLab 3 / 59
Guided lablinux

Linux Security & SSH Hardening

Lock down SSH without locking yourself out, and know how to recover when you inevitably do.

Time
45 min
Level
Beginner
Objectives
4 objectives
Cost
Free

Where this fits in the platform

This lab adds

  • Key-only SSH access, root login disabled

Before you start

You will need

  • A Linux host you can reach another way (console, snapshot, or a second VM)

You do not need these already — the lab environment below provides them.

You will be able to

  • Move from password login to key-only authentication safely
  • Grant administrative access without handing out root
  • Verify a change from a second session before trusting it

CostFree

— a VM, a container, or a spare machine.

Nothing to pay in the browser. Open the terminal runs this against a simulated cloud — the same API calls and the same commands, with no account and no bill. The figure above applies only if you build it in your own.

The scenario#

A server is reachable on port 22 with password authentication and a shared root login. It is being scanned within minutes of being created — that is not paranoia, it is what the auth log shows.

This lab closes it down. The order matters more than the settings: get it wrong and you lock yourself out of a machine you cannot physically reach.

Keep your current session open until the very end. Every step below is verified from a second connection. If something is wrong, the first session is the only way back in.

Hands-on environment

Run this lab in a real terminal, free and in your browser. The environment is temporary and yours alone — break it as much as you like.

Open the terminal

Opens in Killercoda, in a new tab — keep this page open for the steps.

Run it on your own machine

Run this lab on your own machine. One command starts the environment, with everything the lab needs already installed:

Run these against the node1 container rather than the controller — it is the machine with systemd. From the controller: `ssh node1`.

You will need:

  • bash
git clone https://github.com/EgyKode/EgyKode-lab.git
cd EgyKode-lab
./egykode start
./egykode shell
ssh node1

You need Docker and Git installed. Everything else runs inside the environment. The first start downloads it and takes a few minutes; later starts are seconds.

Not sure what you already have? Run: npm run doctor — it checks and changes nothing.

Anything you tick here is your own record. EgyKode cannot see inside that terminal, so the success criteria stay self-assessed even when the environment checks your work for you.

An administrative user that is not root

Step 1 of 7

Success criteria

0 of 4

The concept behind it

Ready to try it without help?Do the challenge

Next up

Lab 3 of 59 on the project path

Linux Networking & TroubleshootingWork a connection failure from the outside in: DNS, route, port, firewall, application — and know which layer you are on.50 minBeginner

Previous: Linux Processes, Services & Logs