Skip to contentমূল লেখায় যান

Topic 02 · Securityটপিক 02 · Security

Network Scanning and Server Hardening

An attacker starts by asking what a server exposes: which ports answer, and which programs listen behind them. This page shows how a tester answers the same question with Nmap, and how a team then shrinks the answer: fewer services, SSH keys instead of passwords, and a firewall.

7 min read7 মিনিটে পড়া যায় · 6 sections6টি সেকশন · 12 sources12টি সোর্স · updated Nov 2026আপডেট: Nov 2026

Close the doors Nmap seesNmap যে দরজা দেখে, সেগুলো বন্ধ করুন

Scan a server, then harden it and rescan to see fewer open ports.একটা সার্ভার scan করুন, তারপর hardening করে আবার scan করুন আর দেখুন খোলা পোর্ট কমে গেছে।

2 min2 মিনিট8 steps8টি ধাপ
  • Open portsখোলা পোর্ট?
  • Password loginsপাসওয়ার্ড লগইনyes
you · Nmapআপনি · Nmapwritten permissionলিখিত অনুমতিServerসার্ভার????????

You’ll learnআপনি শিখবেন

  • Why you need written permission to scanscan-এর জন্য কেন লিখিত অনুমতি লাগে✓
  • What Nmap scans by defaultNmap ডিফল্টভাবে কী scan করে
  • What -sV and ss tell you-sV আর ss কী জানায়
  • How keys and ufw cut the ways inkey আর ufw কীভাবে ঢোকার পথ কমায়
  • Why you rescan after a changeপরিবর্তনের পর কেন আবার scan করবেন

In plain words

A port scan sends probes to the ports of a host and sorts each port by its answer. Nmap recognizes six port states: open, closed, filtered, unfiltered, open|filtered, and closed|filtered Source 1সোর্স 1. Three of them matter most:

StateWhat Nmap means
openAn application is actively accepting TCP connections, UDP datagrams, or SCTP associations on the port Source 1সোর্স 1
closedThe port is reachable, but no application listens on it Source 1সোর্স 1
filteredNmap cannot tell whether the port is open, because packet filtering stops its probes Source 1সোর্স 1

The Nmap documentation puts the security point plainly: each open port is an avenue for attack Source 1সোর্স 1.

Server hardening is the other half of the job: reduce what the server exposes. NIST SP 800-123 advises removing every service, application, and network protocol that the server does not need, and disabling the ones that cannot be removed Source 7সোর্স 7. Removing is better than disabling, because an attack that tries to turn a removed service back on cannot work, and a disabled service can be turned on again by human error Source 7সোর্স 7.

সহজ English

A port scan knocks on the doors (ports) of a computer and notes how each door answers. Nmap knows six answers. Three matter most Source 1সোর্স 1:

The Nmap documentation says it plainly: each open port is a way in for an attacker Source 1সোর্স 1.

Server hardening is the other half: make the server show less. NIST says to remove every service, program, and network protocol that the server does not need, and to turn off the ones that cannot be removed Source 7সোর্স 7. Removing is better than turning off. An attacker cannot turn a removed service back on, and a person can turn a disabled service on again by mistake Source 7সোর্স 7.

বাংলা ব্যাখ্যা

Port scan একটা computer-এর দরজাগুলোতে (port) টোকা দেয় আর দেখে প্রতিটা দরজা কীভাবে সাড়া দেয়। Nmap ছয় রকম অবস্থা চেনে। এর মধ্যে তিনটা সবচেয়ে জরুরি Source 1সোর্স 1:

  • open: দরজার পেছনে একটা program অপেক্ষা করছে আর connection নিচ্ছে Source 1সোর্স 1।
  • closed: দরজায় পৌঁছানো যায়, কিন্তু পেছনে কোনো program নেই Source 1সোর্স 1।
  • filtered: Nmap বুঝতে পারে না দরজা খোলা কি না, কারণ একটা filter তার টোকা আটকে দেয় Source 1সোর্স 1।

Nmap-এর documentation সোজাসুজি বলে: প্রতিটা open port আক্রমণকারীর জন্য ঢোকার একটা পথ Source 1সোর্স 1।

Server hardening হলো কাজের বাকি অর্ধেক: সার্ভার যেন কম জিনিস বাইরে দেখায়। NIST বলে, সার্ভারের যে service, program আর network protocol দরকার নেই, সেগুলো সরিয়ে ফেলুন, আর যেগুলো সরানো যায় না, সেগুলো বন্ধ করুন Source 7সোর্স 7। বন্ধ করার চেয়ে সরিয়ে ফেলা ভালো। সরিয়ে ফেলা service আক্রমণকারী আবার চালু করতে পারেন না, আর বন্ধ করা service মানুষের ভুলে আবার চালু হয়ে যেতে পারে Source 7সোর্স 7।

How it works

How Nmap scans

  • Which ports. By default, Nmap scans the most common 1,000 ports for each protocol. The -p option scans the ports that you name instead Source 2সোর্স 2.
  • Which scan. The TCP SYN scan (-sS) is the default and most popular scan. It sends raw packets, which needs root access on Unix systems Source 3সোর্স 3. When a user does not have raw packet privileges, the TCP connect scan (-sT) is the default Source 3সোর্স 3.
  • What runs there. -sV enables version detection. After the scan finds open ports, version detection interrogates them to learn more about what is actually running Source 4সোর্স 4. An accurate version number helps a lot in deciding which exploits a server is vulnerable to Source 4সোর্স 4.

Permission to scan

The Nmap documentation says that the best way to avoid controversy is to secure written authorization from the target network before any scanning. In a penetration test, this authorization belongs in the Statement of Work Source 6সোর্স 6. Port scanning without authorization is sometimes against the acceptable use policy of an internet provider Source 6সোর্স 6.

The Nmap project gives everyone permission to scan one host for practice: scanme.nmap.org. The permission covers scanning with Nmap only, not exploits or denial-of-service attacks, and the project asks for no more than a dozen scans of that host per day Source 5সোর্স 5.

How a server gets harder to attack

  • See what listens. ss shows sockets: -t TCP, -u UDP, -l only listening sockets, -p the process that uses each socket, and -n numbers instead of service names Source 8সোর্স 8.
  • SSH with keys. In sshd_config, PasswordAuthentication allows password logins, and its default is yes Source 9সোর্স 9. PermitRootLogin defaults to prohibit-password, which turns off password and keyboard-interactive logins for root; no stops root logins completely Source 9সোর্স 9. Ubuntu's guide makes a key pair with ssh-keygen -t ed25519 and copies the public key to the server with ssh-copy-id Source 10সোর্স 10.
  • A firewall. On Ubuntu, ufw is the default firewall configuration tool, and it is disabled at first Source 11সোর্স 11. ufw default deny incoming sets the default policy for incoming traffic Source 12সোর্স 12. A limit rule allows a connection but denies an IP address that tries 6 or more connections within 30 seconds, which helps against brute-force logins Source 12সোর্স 12.

সহজ English

How Nmap scans.

Permission to scan. The Nmap documentation says: get written permission from the owner of the network before you scan. In a penetration test, the permission goes in the Statement of Work Source 6সোর্স 6. Scanning without permission can break the rules of your internet provider Source 6সোর্স 6.

The Nmap project lets everyone scan one practice host: scanme.nmap.org. You may only scan it with Nmap: no exploits and no attacks that stop the service. The project asks for no more than a dozen scans per day Source 5সোর্স 5.

How a server gets harder to attack.

বাংলা ব্যাখ্যা

Nmap কীভাবে scan করে।

  • কোন port। ডিফল্টভাবে Nmap প্রতিটা protocol-এর সবচেয়ে প্রচলিত 1,000টা port দেখে। -p দিলে আপনার বলা port-গুলো দেখে Source 2সোর্স 2।
  • কোন scan। SYN scan (-sS) ডিফল্ট আর সবচেয়ে জনপ্রিয় scan। Unix-এ এর জন্য root access লাগে Source 3সোর্স 3। সেই access না থাকলে Nmap ডিফল্টভাবে TCP connect scan (-sT) চালায় Source 3সোর্স 3।
  • ভেতরে কী চলছে। -sV version detection চালু করে। এটা প্রতিটা open port-কে জিজ্ঞেস করে সেখানে আসলে কী চলছে Source 4সোর্স 4। সঠিক version নম্বর জানলে বোঝা অনেক সহজ হয়, সার্ভারে কোন আক্রমণ কাজ করবে Source 4সোর্স 4।

Scan করার অনুমতি। Nmap-এর documentation বলে: scan করার আগে network-এর মালিকের লিখিত অনুমতি নিন। Penetration test-এ এই অনুমতি Statement of Work-এ থাকে Source 6সোর্স 6। অনুমতি ছাড়া scan করলে আপনার internet provider-এর নিয়ম ভাঙা হতে পারে Source 6সোর্স 6।

Nmap project সবাইকে একটা প্র্যাকটিস host scan করার অনুমতি দেয়: scanme.nmap.org। এটা শুধু Nmap দিয়ে scan করা যাবে: কোনো exploit নয়, service বন্ধ করার আক্রমণও নয়। Project অনুরোধ করে, দিনে এক ডজনের বেশি scan করবেন না Source 5সোর্স 5।

সার্ভারকে কীভাবে আক্রমণের জন্য কঠিন করা হয়।

  • কী শুনছে, দেখুন। ss -tulpn শোনার অবস্থায় থাকা TCP আর UDP socket দেখায়, প্রতিটার পেছনের program সহ, আর নামের বদলে নম্বর দিয়ে Source 8সোর্স 8।
  • Key দিয়ে SSH। sshd_config-এর PasswordAuthentication password দিয়ে login চালু রাখে, আর এর ডিফল্ট yes Source 9সোর্স 9। PermitRootLogin-এর ডিফল্ট prohibit-password: root password দিয়ে login করতে পারেন না। no দিলে root একেবারেই login করতে পারেন না Source 9সোর্স 9। Ubuntu-র গাইড ssh-keygen -t ed25519 দিয়ে key বানায় আর ssh-copy-id দিয়ে সেটা সার্ভারে কপি করে Source 10সোর্স 10।
  • একটা firewall। ufw Ubuntu-র ডিফল্ট firewall tool, আর শুরুতে এটা বন্ধ থাকে Source 11সোর্স 11। ufw default deny incoming ভেতরে আসা traffic-এর ডিফল্ট নিয়ম ঠিক করে Source 12সোর্স 12। limit নিয়ম এমন address আটকে দেয়, যেটা 30 সেকেন্ডে 6 বা তার বেশি connection চেষ্টা করে। এটা password অনুমান করে ঢোকার আক্রমণ ঠেকাতে সাহায্য করে Source 12সোর্স 12।

In practice

1. Scan the lab target. From the Kali container of the practice lab:

nmap juice                 # the 1,000 most common ports
nmap -sV -p 3000 juice     # what runs on port 3000

-p limits the scan to the ports that you name Source 2সোর্স 2, and -sV asks the open port what is running Source 4সোর্স 4. To practise on the internet, use only scanme.nmap.org, with Nmap only, and no more than a dozen scans a day Source 5সোর্স 5.

2. Harden a practice server. On an Ubuntu virtual machine that you own, first list what listens Source 8সোর্স 8:

sudo ss -tulpn

Then turn on the firewall. Ubuntu's guide opens the SSH port with sudo ufw allow 22, turns the firewall on with sudo ufw enable, and shows the rules with sudo ufw status verbose Source 11সোর্স 11. On a remote server, add the SSH rule before you enable the firewall. That order is the tutorial's advice, so that the firewall does not cut your own connection:

sudo ufw default deny incoming
sudo ufw limit 22/tcp
sudo ufw enable
sudo ufw status verbose

limit instead of allow adds the rate limit for brute-force logins Source 12সোর্স 12.

Next, copy your key to the server with ssh-copy-id, and check that a key login works Source 10সোর্স 10. Only then set these two lines in /etc/ssh/sshd_config:

PasswordAuthentication no
PermitRootLogin no

Check the file before you restart SSH: the Ubuntu guide runs sudo sshd -t first, because a broken configuration can cost you the way into the server, and then restarts with sudo systemctl restart ssh.service Source 10সোর্স 10.

3. Scan again. Run the same Nmap scan from step 1 against the server and compare: every port that is still open needs a reason.

সহজ English

1. Scan the lab target. From the Kali container of the practice lab, run the two Nmap commands of the Technical view. -p scans only the ports you name Source 2সোর্স 2. -sV asks the open port what is running there Source 4সোর্স 4. On the internet, practise only on scanme.nmap.org, only with Nmap, and no more than a dozen scans a day Source 5সোর্স 5.

2. Harden a practice server. On an Ubuntu virtual machine that you own, first run sudo ss -tulpn to see what listens Source 8সোর্স 8.

Then turn on the firewall. Ubuntu's guide opens SSH with sudo ufw allow 22, turns the firewall on with sudo ufw enable, and shows the rules with sudo ufw status verbose Source 11সোর্স 11. The tutorial's advice: on a remote server, open SSH before you turn the firewall on, so that you do not lock yourself out. The Technical view uses limit instead of allow, which adds the block for password-guessing attacks Source 12সোর্স 12.

Next, copy your key to the server with ssh-copy-id, and check that a key login works Source 10সোর্স 10. Only then turn off password logins and root logins in /etc/ssh/sshd_config. Check the file with sudo sshd -t before you restart SSH with sudo systemctl restart ssh.service, because a broken file can lock you out of the server Source 10সোর্স 10.

3. Scan again. Run the same scan and compare. Every port that is still open needs a reason.

বাংলা ব্যাখ্যা

1. ল্যাবের target scan করুন। প্র্যাকটিস ল্যাবের Kali container থেকে Technical view-এর দুটো Nmap command চালান। -p শুধু আপনার বলা port-গুলো scan করে Source 2সোর্স 2। -sV open port-কে জিজ্ঞেস করে সেখানে কী চলছে Source 4সোর্স 4। Internet-এ শুধু scanme.nmap.org-এ প্র্যাকটিস করুন, শুধু Nmap দিয়ে, আর দিনে এক ডজনের বেশি scan নয় Source 5সোর্স 5।

2. একটা প্র্যাকটিস সার্ভার hardening করুন। আপনার নিজের একটা Ubuntu virtual machine-এ আগে sudo ss -tulpn চালিয়ে দেখুন কী শুনছে Source 8সোর্স 8।

এরপর firewall চালু করুন। Ubuntu-র গাইড sudo ufw allow 22 দিয়ে SSH খোলে, sudo ufw enable দিয়ে firewall চালু করে, আর sudo ufw status verbose দিয়ে নিয়মগুলো দেখায় Source 11সোর্স 11। টিউটোরিয়ালের পরামর্শ: দূরের সার্ভারে firewall চালু করার আগে SSH খুলে নিন, যাতে আপনি নিজেই আটকে না যান। Technical view allow-এর বদলে limit ব্যবহার করে, যেটা password অনুমান করে ঢোকার আক্রমণ আটকানোর নিয়মও যোগ করে Source 12সোর্স 12।

এরপর ssh-copy-id দিয়ে আপনার key সার্ভারে কপি করুন, আর দেখুন key দিয়ে login কাজ করে কি না Source 10সোর্স 10। তারপরই /etc/ssh/sshd_config-এ password login আর root login বন্ধ করুন। SSH restart করার আগে (sudo systemctl restart ssh.service) sudo sshd -t দিয়ে ফাইলটা যাচাই করুন, কারণ ভুল ফাইল আপনাকে সার্ভার থেকে আটকে দিতে পারে Source 10সোর্স 10।

3. আবার scan করুন। একই scan চালিয়ে তুলনা করুন। যে port এখনো খোলা, তার প্রতিটার একটা কারণ থাকতে হবে।

Common mistakes

সহজ English

বাংলা ব্যাখ্যা

  • লিখিত অনুমতি ছাড়া network scan করা। Nmap-এর documentation বলে, আগে লিখিত অনুমতি নিন Source 6সোর্স 6। আইন জানতে Cyber Law and Data Protection দেখুন।
  • প্র্যাকটিস host-এ scan-এর বেশি কিছু করা। scanme.nmap.org শুধু Nmap দিয়ে scan করা যাবে। কোনো exploit নয়, service বন্ধ করার আক্রমণও নয় Source 5সোর্স 5।
  • ভাবা যে সাধারণ nmap সব port দেখেছে। এটা প্রতিটা protocol-এর সবচেয়ে প্রচলিত 1,000টা port দেখে Source 2সোর্স 2।
  • "filtered"-কে "নিরাপদ" ভাবা। Filtered মানে Nmap বুঝতে পারেনি port খোলা কি না Source 1সোর্স 1।
  • সরানো যায় এমন service শুধু বন্ধ রাখা। NIST সরিয়ে ফেলা পছন্দ করে, কারণ বন্ধ service আবার চালু হয়ে যেতে পারে Source 7সোর্স 7।
  • Key login কাজ করার আগেই password login বন্ধ করা। Ubuntu-র গাইডে ssh-copy-id দিয়ে কপি করা key থাকলে password ছাড়াই login করা যায় Source 10সোর্স 10। PasswordAuthentication no দেওয়ার আগে সেই login পরীক্ষা করুন।
  • ফাইল যাচাই না করে SSH restart করা। আগে sudo sshd -t চালান Source 10সোর্স 10।

What a tester can check

Tutorial advice

This list is the tutorial's own advice, not a fact from a source.

  • Only the expected ports are open. Keep a list of the ports that the server should expose, and compare every scan with it.
  • A scan before and after each change. Save both outputs with the date (nmap -oN before.txt ...) so that the report can show the difference.
  • Password logins are refused. ssh -o PubkeyAuthentication=no user@server must fail.
  • Root cannot log in. ssh root@server must fail, also with a key.
  • The firewall is on, with deny as the default. sudo ufw status verbose shows Status: active and the default for incoming traffic.
  • Versions are current. Each version that -sV reports is checked against the vendor's security advisories.

সহজ English

Tutorial advice

This list is the tutorial's own advice, not a fact from a source.

  • Only the expected ports are open. Keep a list of the ports the server should show, and compare every scan with it.
  • Scan before and after each change. Save both results with the date, so that the report can show what changed.
  • Password logins are refused. A login that refuses to use a key must fail.
  • Root cannot log in. A login as root must fail, also with a key.
  • The firewall is on, and it blocks by default. sudo ufw status verbose shows that it is active and what it does with incoming traffic.
  • Versions are up to date. Check each version that -sV shows against the maker's security notices.

বাংলা ব্যাখ্যা

Tutorial advice

এই তালিকা টিউটোরিয়ালের নিজের পরামর্শ, কোনো source থেকে নেওয়া তথ্য নয়।

  • শুধু প্রত্যাশিত port খোলা। সার্ভারের কোন port খোলা থাকার কথা, তার একটা তালিকা রাখুন, আর প্রতিটা scan সেটার সঙ্গে মিলিয়ে দেখুন।
  • প্রতিটা পরিবর্তনের আগে ও পরে scan। দুটো ফলাফলই তারিখসহ সংরক্ষণ করুন, যাতে রিপোর্টে পার্থক্য দেখানো যায়।
  • Password login প্রত্যাখ্যাত হয়। Key ব্যবহার না করা login fail করতে হবে।
  • Root login করতে পারেন না। root হিসেবে login fail করতে হবে, key দিয়েও।
  • Firewall চালু, আর ডিফল্টভাবে আটকায়। sudo ufw status verbose দেখায় এটা active কি না আর ভেতরে আসা traffic-এর সঙ্গে কী করে।
  • Version হালনাগাদ। -sV যে version দেখায়, প্রতিটা নির্মাতার security notice-এর সঙ্গে মিলিয়ে দেখুন।

Key words

TermMeaning
PortA numbered endpoint on a host where a program can listen for connections.
Open portA port where an application accepts connections.
Closed portA reachable port with no application listening.
Filtered portA port that Nmap cannot classify, because a filter blocks its probes.
SYN scan (-sS)Nmap's default scan when it may send raw packets.
Version detection (-sV)Nmap asks the open ports what service and version run there.
HardeningMaking a system expose less: fewer services, fewer ways in.
sshd_configThe configuration file of the OpenSSH server.
ufwUncomplicated Firewall, Ubuntu's default firewall configuration tool.
Rate limitA rule that blocks a source that connects too often in a short time.
Statement of WorkThe contract of a penetration test, where the scan authorization belongs.
  1. [1]
    Port Scanning Basics

    Nmap Reference Guide · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  2. [2]
    Port Specification and Scan Order

    Nmap Reference Guide · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  3. [3]
    Port Scanning Techniques

    Nmap Reference Guide · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  4. [4]
    Service and Version Detection

    Nmap Reference Guide · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  5. [5]
    Examples

    Nmap Reference Guide · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  6. [6]
    Legal Issues

    Nmap Network Scanning · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  7. [7]
    SP 800-123, Guide to General Server Security

    NIST · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  8. [8]
    ss(8)

    Linux manual pages (man7.org) · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  9. [9]
    sshd_config(5)

    OpenBSD manual pages · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  10. [10]
    OpenSSH server

    Ubuntu Server documentation · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  11. [11]
    Firewall

    Ubuntu Server documentation · accessed 2026-11-15দেখা হয়েছে: 2026-11-15

  12. [12]
    ufw(8)

    Ubuntu manpages · accessed 2026-11-15দেখা হয়েছে: 2026-11-15