Ravindra BagaleCourses & study guides मराठी Track your progress

2. Ports and Protocols: SSH, HTTP, HTTPS, FTP/SFTP and DNS

Chala mitrano, IP ne aapan machine paryant pohochlo. Pan tya machine var konta program uttar deil – web server, SSH ki MySQL? Te port tharavto. Aaj aapan ports aani mahatvache protocols – SSH, HTTP, HTTPS, FTP/SFTP aani DNS – shiknar aahot. Pudhe Nmap scan kartana hech ports tumhala "open" kiwa "closed" distil, mhanun he chapter nit lakshat theva.

What you will learn in this chapter

  • Port ranges and the well-known ports every security professional must know
  • SSH: how key-based login works and why port 22 is attacked so often
  • HTTP: requests, methods, headers and status codes
  • HTTPS and TLS basics: certificates, the handshake and encryption (कूटबद्धीकरण)
  • FTP vs SFTP, and why plain FTP is dangerous
  • DNS basics: resolution, record types and DNS as an attack surface

Concepts in this chapter

  1. 2.1Ports and the Well-Known Port List
  2. 2.2SSH (Secure Shell) – Port 22
  3. 2.3HTTP – Port 80
  4. 2.4HTTPS and TLS Basics – Port 443
  5. 2.5FTP and SFTP
  6. 2.6DNS Basics – Port 53

The chapter recap is at the end of the last concept page.

Chapter 2: Ports and protocols — practice tasks

Open chapter lessons · Full guided lab: check listening ports and turn on firewall (not repeated here)

2.1 List listening ports on your own VM

EasyIT

Why: An open port you don't know about is a door you forgot to lock.

What: On your own Linux VM, list every listening TCP port and the program behind it.

How:

  1. Run sudo ss -tulpn.
  2. Look at the Local Address column (e.g. 0.0.0.0:22).
  3. Note the program name in the Process column.
  4. Mark which ports listen on 0.0.0.0 (all interfaces) vs 127.0.0.1 (local only).

Expected output: At least :22 sshd. If nginx is installed, :80 nginx.

Hint

0.0.0.0 or [::] means reachable from the network.

Answer / how to check
  1. Every listening port must have a known owner.
  2. Anything you can't explain: stop the service or block it in the firewall.

2.2 Match ports to services for a retail store server

EasyRetail

Why: Shop servers in Bengaluru or Toronto often expose FTP by mistake. You must recognise risky ports fast.

What: Use the data file. Name the protocol and say Keep, Replace or Close.

Data file: store-ports.csv

PortSeen on
21POS-server, Bengaluru
22POS-server, Bengaluru
23Old-router, Toronto
443Web-shop, Toronto
3306POS-server, Bengaluru

About this file: Made-up scan results from a shop's own servers. Each row is one open port. Columns: Port = port number; Seen on = which server and city.

How:

  1. Look up each port in the chapter's well-known port list.
  2. Decide if the protocol encrypts traffic.
  3. Choose Keep (needed and safe), Replace (use a safe version) or Close.

Expected output: 21 FTP → Replace with SFTP; 22 SSH → Keep (keys only); 23 Telnet → Close; 443 HTTPS → Keep; 3306 MySQL → Close to the internet (localhost only).

Hint

Telnet and FTP send passwords in plain text.

Answer / how to check
  1. Check that only 22 and 443 stay open to the outside.

2.3 Test a port with nc and curl on localhost

MediumLogistics

Why: Before opening a firewall rule you should prove a service works locally.

What: Start a tiny Python web server on port 8080 and test it.

How:

  1. Run python3 -m http.server 8080 --bind 127.0.0.1 in one terminal.
  2. In another run nc -zv 127.0.0.1 8080.
  3. Then run curl -I http://127.0.0.1:8080/.
  4. Stop the server with Ctrl+C and run nc again.

Expected output: nc says 'succeeded'/'open'; curl shows HTTP/1.0 200 OK. After stopping, nc says 'Connection refused'.

Hint

Install nc with sudo apt install netcat-openbsd.

Answer / how to check
  1. The before/after difference proves the port belongs to that program.

Extended teaching notes

Why this lesson matters

Hardening is deleting unnecessary risk: fewer packages, fewer open ports, fewer privileged accounts, faster patches, better logs.

Hardening related services

[('SSH', 'Key auth, no root login, Fail2ban or equivalent, SG limited to your IP/VPN.', '', ''), ('SMB / NFS / LDAP / SNMP', 'Do not expose to the internet; patch; strong auth; disable unused versions (e.g. SMBv1).', '', ''), ('SMTP', 'Authenticated relay only; SPF/DKIM/DMARC for your domains.', '', ''), ('DNS', 'Restrict zone transfers; monitor for unexpected records (crt.sh for certs).', '', ''), ('Firewalls', 'Host firewall + cloud SG/NSG; default deny; document every allow.', '', '')]

Real examples

Global: CIS Benchmarks exist for Linux, Windows and clouds. Indian company (sample): a Pune team requires SSH keys only and weekly patch windows for internet-facing hosts.

Mini case study

Suppose we are on a purple-team exercise for an Indian mid-size company (sample data). Red notes a technique from this lesson against a lab clone. Blue must show the control that stops it, the log that would have fired, and the ticket that hardens production. That is the standard this course trains you for.

Defender's worksheet (do this today)

  1. Write the lesson title, date and the exact lab target you are allowed to use.
  2. List three owned systems (VMs, apps, or cloud accounts) where this lesson applies.
  3. Run one safe check from the lesson on a lab system only. Paste the command and output.
  4. Write a two-sentence fix you would give a teammate.
  5. Name one related public advisory (CERT-In, CISA, NVD, or a vendor bulletin) with its date.

Indian workplace (sample data)

Suppose we are a junior analyst at Infosys, TCS, Wipro or a fintech SOC in Bengaluru/Pune. Turn this lesson into one checklist item with an owner, a due date and a place to store evidence (ticket + screenshot).

Global practice

Compare your notes with OWASP, CIS Benchmarks, NIST CSF/IR guidance or a cloud Well-Architected security question. Write five lines on what overlaps.

Everyday analogy

Explain the risk and the fix to a family member without jargon. If they can repeat the warning, you understand it well enough to teach juniors.

Key terms

  • Control: a safeguard (patch, config, process, detection).
  • Finding: a weakness backed by evidence.
  • Remediation: the fix plus how you verified it.
  • Scope: systems you have written permission to touch.
  • Least privilege: only the access the task needs.
  • Defence in depth: several layers so one failure does not end the story.

Common mistakes

  • Skipping written permission "just for a quick scan".
  • Practising on hostel, office or public targets without authorisation.
  • Collecting tool output without writing the fix.
  • Copying attack steps onto production to "verify". Defenders verify with versions, configs and patches.
  • Publishing screenshots that contain secrets, cookies or internal hostnames.

Recap

  • Evidence, fix, owner, date.
  • Own lab only.
  • Fix > spectacle.

Extra depth

Re-read the original short section at the top of the page, then this expansion. Together they should exceed a solid lesson length. If anything still feels thin, add your own lab screenshot and a paragraph in your notebook — that personal evidence is what interviews ask for.

  • Permission before tools.
  • Patch and config before exploits.
  • Logs and backups before blame.
  • Teach one junior the warning from this page.