RousselTMLEARNING

TP · Linux administration: from discovery to expertise

Lab: Network troubleshooting, key-based SSH and firewall

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. 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. 2. Troubleshoot resolution and connections

    Why? Go up the layers: DNS, port, then application.

    Resolve a name with dig and getent, test a port with nc, inspect an HTTPS request with curl -v, and capture DNS traffic during a lookup.
  3. 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 with ss, test from the VM's IP address, then restart it on 0.0.0.0.
  4. 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 a tp host in ~/.ssh/config and connect.
  5. 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 with sshd -t, reload and check a key-less connection is refused. Keep your session open.
  6. 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. 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

  • ⏱ Estimated time : ≈ 45 min

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.

Ask a question about this lesson →

Recommended Articles

Networking on Linux: configuration, diagnosis, firewall and SSH

Configure and troubleshoot Linux networking: ip, ss, netplan and NetworkManager, DNS, layered dia...

Windows networking: IP, DNS, DHCP, firewall and remote access

Configure and troubleshoot Windows networking with PowerShell, deploy a DHCP server, master Windo...

Linux administration best practices

Checklist for administering Linux servers: accounts and sudo, SSH, updates, systemd services, sto...

Ansible: managing security (Vault, SSH, privileges and secrets)

Securing Ansible: Ansible Vault, SSH key authentication, become and sudo, no_log, hardening the c...

Google Cloud networking: global VPC, subnets, firewall and load balancing

Design networking on Google Cloud: global VPC and regional subnets, firewall rules based on tags ...

Linux server security and hardening

Harden a Linux server: least privilege, updates, secure SSH, firewall, fail2ban, SELinux and AppA...

Backup, monitoring and troubleshooting of a Linux server

Operate a Linux server day to day: 3-2-1 backup strategy with rsync, tar, LVM snapshots and resti...

Linux vs Unix: the complete guide to commands and distributions

Understand the differences between Linux and Unix, explore distributions (server, desktop, lightw...

Identities and access on OVHcloud: account, IAM, OpenStack users and keys

Secure access to OVHcloud: two-factor authentication on the account, OVHcloud IAM (identities, po...

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!