install samba | zuhdi.org

Install Samba

Environment

  • Debian 9.7 x64
  • Samba Server 4.5.16
  • Samba Client 4.5.16

Log 2019 / 06

1. Install & Configure Samba Server

root@athos:~# apt-get -y update && apt-get -y upgrade && apt-get -y dist-upgrade

root@athos:~# apt-get -y --no-install-recommends install samba

root@athos:~# dpkg -l | grep -E samba
ii  python-samba       2:4.5.16+dfsg-1+deb9u2   amd64   
  ython bindings for Samba
ii  samba              2:4.5.16+dfsg-1+deb9u2   amd64   
  SMB/CIFS file, print, and login server for Unix
ii  samba-common       2:4.5.16+dfsg-1+deb9u2   all     
  common files used by both the Samba server and client
ii  samba-common-bin   2:4.5.16+dfsg-1+deb9u2   amd64   
  Samba common files used by both the server and the client
ii  samba-libs:amd64   2:4.5.16+dfsg-1+deb9u2   amd64   
  Samba core libraries

root@athos:~# samba -V
Version 4.5.16-Debian

root@athos:~# smbpasswd -a root
New SMB password:
Retype new SMB password:
Added user root.

root@athos:~# smbpasswd -e root
Enabled user root.

root@athos:~# mkdir -p /public/samba/

root@athos:~# usermod -aG sambashare root
sent invalidate(passwd) request, exiting
sent invalidate(group) request, exiting
sent invalidate(passwd) request, exiting
sent invalidate(group) request, exiting

root@athos:~# id root
uid=0(root) gid=0(root) groups=0(root),113(sambashare)

root@athos:~# vi /etc/samba/smb.conf
[public-samba]
  path = /public/samba/
  browseable = yes
  read only = no
  force create mode = 0660
  force directory mode = 2770
  valid users = @sambashare

root@athos:~# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[public-samba]"
Loaded services file OK.
Server role: ROLE_STANDALONE

Press enter to see a dump of your service definitions
(truncated)

root@athos:~# systemctl restart nmbd.service

root@athos:~# systemctl restart smbd.service

2. Install & Configure Samba Client

root@chimera:~# apt-get -y update && apt-get -y upgrade && apt-get -y dist-upgrade

root@chimera:~# apt-get -y --no-install-recommends install cifs-utils smbclient

root@chimera:~# smbclient --version
Version 4.5.16-Debian

root@chimera:~# smbclient -L athos.host
Enter root's password:
Anonymous login successful
Domain=[WORKGROUP] OS=[Windows 6.1] Server=[Samba 4.5.16-Debian]

        Sharename       Type      Comment
        ---------       ----      -------
        public-samba    Disk
        IPC$            IPC       IPC Service (Samba 4.5.16-Debian)
Anonymous login successful
Domain=[WORKGROUP] OS=[Windows 6.1] Server=[Samba 4.5.16-Debian]

        Server               Comment
        ---------            -------
        ATHOS                Samba 4.5.16-Debian

        Workgroup            Master
        ---------            -------
        WORKGROUP            ATHOS

root@chimera:~# mount -o username=root //athos.host/public-samba /mnt
Password for root@//athos.host/public-samba:  ********

root@chimera:~# mount | grep athos.host
//athos.host/public-samba on /mnt type cifs 
  (rw,relatime,vers=1.0,cache=strict,username=root,domain=ATHOS,uid=0,noforceuid,gid=0,
  noforcegid,addr=206.189.81.181,unix,posixpaths,serverino,mapposix,acl,rsize=1048576,
  wsize=65536,echo_interval=60,actimeo=1)

root@chimera:~# vi /etc/fstab
# /etc/fstab: static file system information.
UUID=8add0c4f-baf9-4734-846d-cb9bd4761926  /     ext4  errors=remount-ro            0 1
//athos.host/public-samba       /mnt  cifs  _netdev,username=root,password=p@ssw0rd 0 0

root@chimera:~# mount -a

root@chimera:~# mount | grep athos.host
//athos.host/public-samba on /mnt type cifs 
  (rw,relatime,vers=1.0,cache=strict,username=root,domain=ATHOS,uid=0,noforceuid,gid=0,
  noforcegid,addr=206.189.81.181,unix,posixpaths,serverino,mapposix,acl,rsize=1048576,
  wsize=65536,echo_interval=60,actimeo=1,_netdev)

Hugo. Malte Kiefer & Zuhdi Najib.