Skip to content
Français
Account: not signed in, sync available My learning
Select theme
Français

SMB/CIFS: network file sharing with Samba

By updated

Improve this page

SMB (Server Message Block) is the network file and printer sharing protocol, born in the Windows world. A client mounts a remote shared folder and uses it like a local disk, on TCP port 445. On Linux, the open source implementation is called Samba. This guide explains the difference between SMB and CIFS, how to access a share with smbclient, audit a server with nmap, and harden a Samba configuration. For administrators and blue team profiles, on the command line.

What you will learn

  • The difference between SMB, CIFS and Samba.
  • The versions of SMB and why SMB1 is dangerous.
  • Access a share with smbclient and mount it.
  • Audit an SMB server with nmap.
  • Harden a Samba configuration.

What are SMB and CIFS?

SMB is the protocol that lets machines share files and printers. Created by IBM in the 80s then extended by Microsoft, it is the mechanism behind corporate network drives and most NAS devices (Synology, TrueNAS, QNAP).

The term CIFS (Common Internet File System) is confusing. It is not a separate protocol: it is the name Microsoft gave in 1996 to a variant of SMB1.

TermReality
CIFSold name of SMB1
SMBthe current protocol (SMB2, SMB3)
Sambathe open source implementation for Linux

Remember the simple rule: CIFS = SMB1, an obsolete dialect. When you mount a share with mount -t cifs, you are actually using a modern SMB client; the cifs name stayed for historical reasons.

SMB versions

Choosing the right version is first of all a matter of security. Three generations coexist, and the first one must disappear.

VersionIntroducedKey point
SMB1 (CIFS)90sobsolete, EternalBlue vector, to disable
SMB2Windows Vista / Server 2008signing available, no encryption
SMB3Windows 8 / Server 2012encryption available, to require on the server side
SMB 3.1.1Windows 10 / Server 2016AES-128-GCM encryption, pre-auth integrity

On the network side, two ports come into play: TCP 445 (SMB directly over TCP, the standard) and TCP 139 (historical SMB encapsulated in NetBIOS). In practice, you watch 445.

Samba: SMB on Linux

Samba is the open source implementation of the SMB protocol for Linux and Unix. It lets a Linux server share files with Windows, macOS and Linux clients, and can even act as an Active Directory domain controller. The current stable version is Samba 4.25, released on 24 September 2026 (read on download.samba.org).

Its configuration lives in /etc/samba/smb.conf: a [global] section for the general settings, then one block per share. A minimal share looks like this:

[partage]
path = /srv/partage
valid users = alice
read only = no

Access a share from the command line

The reference client is smbclient (smbclient package on Debian/Ubuntu, samba-client on RHEL/Fedora). The outputs below come from a real lab: a Samba server in a container exposing a partage share.

  1. List the shares of a server, after authentication:

    Terminal window
    smbclient -L //serveur -U alice
    Sharename Type Comment
    partage Disk
    IPC$ IPC IPC Service (Samba Server)
  2. Connect to a share: the session is interactive, like an FTP client (ls, get, put, cd):

    Terminal window
    smbclient //serveur/partage -U alice
  3. Mount the share as a file system with cifs-utils:

    Terminal window
    sudo mount -t cifs //serveur/partage /mnt -o username=alice

    Do not force vers=3.0, contrary to what you read everywhere: automatic negotiation gives a higher dialect, and this guide also hardens the server in a way that makes vers=3.0 incompatible.

Audit an SMB server

Before securing, you must see what an attacker sees. Two checks matter: the accepted versions and anonymous access.

nmap enumerates the supported SMB dialects. On the lab, the server accepts SMB 2.1 and 3.0, but not SMB1, which is the expected behaviour:

Terminal window
nmap -p445 --script smb-protocols serveur
445/tcp open microsoft-ds
| smb-protocols:
| dialects:
| 2.1
| 3.0

The second test is anonymous access (null session). On the lab, listing the shares without authentication succeeds, which reveals the share to anyone:

Terminal window
smbclient -L //serveur -N
Sharename Type Comment
partage Disk

Harden a Samba configuration

SMB security rests on a few directives in the [global] section of smb.conf. The goal: refuse old protocols, encrypt, sign and block anonymous access.

[global]
server min protocol = SMB3 # alias of SMB3_11: refuses SMB1, SMB2 and SMB3.0
smb encrypt = required # mandatory encryption (SMB3)
server signing = mandatory # enforced signing (anti NTLM relay)
restrict anonymous = 2 # cuts off null sessions

Each line closes a concrete flaw:

  • server min protocol = SMB3 rules out SMB1 (EternalBlue) and unencrypted SMB2;
  • smb encrypt = required encrypts the exchanges (only effective with SMB3);
  • server signing = mandatory against NTLM relay (SMB relay);
  • restrict anonymous = 2 cuts off null sessions.

Complete with valid users on each share to restrict access, and above all: never expose port 445 on the Internet. SMB stays confined to the local network, behind a firewall.

Put it into practice

Mount an SMB/CIFS share in a persistent and safe way on a VM: credentials in a protected file, entry in /etc/fstab, and a check of the mount after reboot.

Key points

  • SMB is the network file sharing protocol; Samba is its open source Linux implementation.
  • CIFS = SMB1, an obsolete dialect to disable (EternalBlue, WannaCry).
  • The port to watch is TCP 445; 139 is historical (NetBIOS).
  • On the CLI client side: smbclient -L lists, smbclient //srv/share connects, mount -t cifs mounts. Do not force vers=3.0: negotiation gives 3.1.1, and vers=3.0 breaks the mount on a server with server min protocol = SMB3.
  • Audit with nmap --script smb-protocols and test anonymous access (null session).
  • Harden Samba: server min protocol = SMB3, smb encrypt = required, restrict anonymous = 2.
  • Never expose port 445 on the Internet.

Knowledge check

Check that the essentials of this guide are acquired. The questions only cover what has just been explained here.

Knowledge check

Check what you have learned with this interactive quiz

6 questions
6 min
70% to pass

How it works

  • The timer starts when you click Start
  • Multiple choice, true/false and short answer questions
  • You can move between questions
  • Detailed results are shown at the end

Starts the quiz and the timer

FAQ: frequently asked questions about SMB/CIFS

These answers cover the most frequent questions about SMB: the difference with CIFS, port 445, the smbclient commands and the danger of SMB1.

Is this project useful to you?

The guides, courses, quizzes and labs stay free. If you use them regularly, you can contribute to their upkeep and development.

Become a supporting member (new tab) One-time support (new tab) Learn more

Follow the project on LinkedIn