SMB

UNIX systems also need to share files with systems, such as Windows, that don’t natively support NFS. Enter SMB.

History

  • 1980s BAF was created (the creators intials), before its release it was renamed to SMB (Server message block), Microsoft picked up the protocol.
  • 1996, a version called the Common Internet File System (CIFS) was released by Microsoft, mostly as a marketing exercise. CIFS added buggy changes.
  • 2006 Microsoft releases SMB 2.0
  • 2012 Microsoft releases SMB 3.0

Although it’s common within the industry to refer to SMB fileshares as CIFS, the truth is that CIFS was deprecated long ago; only SMB lives on. Like SSL and TLS.

Samba

[PITHY] Samba is a UNIX/Linux version of SMB server side.

It offers a stable, industrial strength way to share files between UNIX and Windows systems. The real beauty of Samba is that you install only one package on the server side; no special software is needed on the Windows side.

Sambda has two daemons:

  • smbd print services and authentication/authorization
  • nbmd name resolution and service announcement

Samba is a user level process.

  1. It binds to the sockets used for SMB requests and waits for a client to request access to a resource.
  2. Once a request has been authenticated, smbd forks an instance of itself that runs as the user who is making the requests.
  3. As a result, all normal file access permissions (including group permissions) are obeyed.

Question

Why would you choose SMB over NFS?

Answer

the answer is ubiquity. Almost all OSs support SMB

Install and Configuration

Configure Samba in the /etc/samba/smb.conf.
The file specifies the directories to share, their access rights, and Samba’s general operational parameters

Run the command testparm -v for a listing of all the Samba configuration options and the values to which they are currently set.

Authentication

Two ways:

  1. Local accounts on the host Samba server. The client provides the corresponding account and password that is stored on the UNIX server.
  2. Integrate Active Directory authentication and so piggybacks on the user’s domain login credentials.

Configuring Shares

Each share that you expose needs its own stanza in the configuration file. The name of the stanza becomes the share name that is advertised to SMB clients.

[bookshare]
    path = /storage/bookshare
    read only = no

Clients will mount as \\sambaserver\bookshare.

Another useful config, you can automatically convert users’ home directories into distinct SMB shares with the magic stanza name [homes] in the smb.

Sharing Project directories

Say you have a group of users who want share a project folder.

You can use windows ACLs or Unix groups. Windows ACLs can be complex.

[eng]
comment = Group Share for engineering
; Everybody who is in the eng group may access this share.
; People will have to log in with their Samba account.
valid users = @eng
path = /home/eng

; Disable NT ACLs since we do not use them here.
nt acl support = no

; Make sure that all files have sensible permissions and that dirs
; have the setgid (inherit group) bit set.
create mask = 0660
directory mask = 2770
force directory mode = 2000
force group = eng

; Normal share parameters.
browseable = no
read only = no
guest ok = no

When a user attempts to mount this share, Samba checks that the applicant is in the appropriate UNIX group before allowing access.

Client Mounting

You need local permission to perform an SMB mount. You also need the password for an identity that the remote SMB server will allow to mount the share. A typical command line on Linux is:

Bash
sudo mount -t cifs -o username=mat //redmond/joes /home/joe/mnt

Samba has a tool called smbclient that lets you browse file shares without actually mounting them.

Debugging Samba

Samba has too sources for debugging:

  • smbstatus - shows currently active connections and locked files
  • Samba’s logging - configured in smb.conf, you can set verbose logging for access