What you will learn in this TP
- Troubleshoot layer by layer
- Set up and harden key-based SSH
- Filter with a firewall
Introduction #
What you will learn in this section
- Troubleshoot layer by layer
- Set up and harden key-based SSH
- Filter with a firewall
Context. A freshly installed server accepts SSH passwords and has no firewall. A developer also complains that a service "answers on the server but not from my laptop".
Prerequisites: a disposable Ubuntu 24.04 VM with console access (in case of an SSH or firewall mistake) · Estimated time: 45 min
Key-only SSH access, a default-deny firewall and a correctly exposed service.Hands-on #
Guided steps, with their solution.
1. Take a network inventory
Why? Knowing addresses, routes, DNS and open ports is the prerequisite for any troubleshooting.
Note interfaces and addresses, the default gateway, DNS servers and listening ports.2. Troubleshoot resolution and connections
Why? Go up the layers: DNS, port, then application.
Resolve a name withdigandgetent, test a port withnc, inspect an HTTPS request withcurl -v, and capture DNS traffic during a lookup.3. Fix "it only works locally"
Why? A service listening on 127.0.0.1 is invisible from the network: ss shows it immediately.
Start an HTTP server on 127.0.0.1:8000, see the listening address withss, test from the VM's IP address, then restart it on 0.0.0.0.4. Switch SSH to key authentication
Why? A protected ed25519 key is far safer than a password, and a config file avoids retyping options.
Generate a key, install it for your account (connecting to localhost for the lab), declare atphost in~/.ssh/configand connect.5. Harden the SSH server
Why? Forbidding root and passwords defeats brute-force attacks.
Create a file in/etc/ssh/sshd_config.d/forbidding root and passwords, validate withsshd -t, reload and check a key-less connection is refused. Keep your session open.6. Enable the firewall
Why? Deny everything by default, then open only what is needed, to the sources that need it.
With ufw: default deny incoming, allow SSH, allow port 8000 only from the VM's private network. Enable it, then look at the generated nftables rules.7. Create an SSH tunnel
Why? A tunnel gives access to an internal service without opening its port in the firewall.
Forward local port 9000 to the server's port 8000 through SSH, test with curl, then stop the tunnel and the HTTP server.
Difficulty level : ●●○○○ (2/5)
My progress
Sign in to track your progress and take notes. Sign in
💬 Questions about this lesson
No questions yet: be the first to ask for help or share your configuration.
Recommended Articles
Container network security and Kubernetes networking
Secure the container network: how Docker and Kubernetes networking works, CNI, default-deny Netwo...
Processes, memory and performance: monitoring and troubleshooting a Linux server
Understand and control Linux processes (ps, top, signals, nice, jobs), interpret load, memory and...
CrowdSec bouncers: principles and firewall bouncer
Understanding CrowdSec bouncers: where to block, live and stream modes, API keys, decisions API, ...
Backup, Hyper-V and Windows troubleshooting
Back up and restore with Windows Server Backup (including system state and Active Directory), vir...
Azure networking: VNet, NSG, peering, load balancing and hybrid connectivity
Design networking on Azure: virtual networks and subnets, network security groups (NSG), peering ...
CrowdSec: understanding the collaborative firewall
What CrowdSec is, how it detects and blocks attacks: Security Engine, parsers, scenarios, Local A...
The Bash shell and files: navigation, redirections, pipes and text processing
Master the Linux command line: paths, file handling, wildcards, redirections, pipes, searching wi...
Users, groups, sudo and permissions on Linux
Manage Linux accounts (useradd, usermod, passwd, chage), groups, sudo and visudo, rwx and octal p...
Packages, systemd services, logs and scheduled tasks
Install and update software with apt and dnf, manage services with systemctl, write a systemd uni...