Post

Samba (SMB)

Samba (SMB)

Samba is the standard Windows interoperability suite of programs for Linux and Unix. Since 1992, Samba has provided secure, stable and fast file and print services for all clients using the SMB/CIFS protocol, such as all versions of DOS and Windows, OS/2, Linux and many others.

Installation

1
apt install samba smbclient

Configuration

Before you edit /etc/smb.conf I’d recommend to make a copy of the original.

1
cp -v /etc/samba/smb.conf{,.orig}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
[global]
        workgroup = WORKGROUP
        server role = standalone server
        passdb backend = tdbsam
        usershare allow guests = Yes
[share]
        comment = share dir
        path = /path/to/share
        read only = No
        store dos attributes = Yes
        inherit acls = Yes
[homes]
        comment = Home Directories
        valid users = %S
        browseable = No
        read only = No
        inherit acls = Yes
        create mode = 0600
        directory mode = 0700
[admin]
        path = /path/to/admin/share
        comment = admin share
        valid users = root @sudo @wheel
        browseable = No
        read only = No
        inherit acls = Yes
        create mode = 0600
        directory mode = 0700
[nobody]
	browsable = no

Highly recommended:

1
man smb.conf

Searching with /^ *keyword press n to move to the next and N for the previous match.

You have to set user passwords twice per added user to SMB server and the user has to be in sambashare groups.

1
2
3
useradd -m user -s /bin/bash -g sambashare
passwd user
smbpassword -a user

Usage

1
systemctl enable smbd.service
1
systemctl ( start | stop | restart | status ) smbd.service

Testing if your shares are available.

1
smbclient -N -L localhost
parameterdescription
-NMeans without authentication, remove it if authentication is needed.
-LList all available shares.
localhostIt’s better to insert the IP of the SMB server here.

Connect to a share

1
smbclient -U username%password //target/share

Troubleshooting

1
journalctl -u smbd.service -f -n20
1
systemctl ( start | stop | restart | status ) smbd.service
This post is licensed under CC BY 4.0 by the author.