Skip to content
Vlad edited this page May 20, 2020 · 1 revision

Samba

Server configuration

# Install
sudo apt-get -y update
sudo apt-get -y install samba

# David
sudo mkdir /samba/
sudo chown :sambashare /samba/
sudo mkdir /samba/david
sudo adduser --home /samba/david --no-create-home --shell /usr/sbin/nologin --ingroup sambashare david
sudo chown david:sambashare /samba/david/
sudo chmod 2770 /samba/david/
sudo smbpasswd -a david # Adds/Updates password
sudo smbpasswd -e david # Enables user if it was disabled

# Everyone
sudo mkdir /samba/everyone
sudo adduser --home /samba/everyone --no-create-home --shell /usr/sbin/nologin --ingroup sambashare admin
sudo chown admin:sambashare /samba/everyone/
sudo chmod 2770 /samba/everyone/
sudo smbpasswd -a admin # Adds/Updates password
sudo smbpasswd -e admin # Enables user if it was disabled
sudo groupadd admins
sudo usermod -G admins admin
# /etc/samba/smb.conf
[global]
  # Server information
  netbios name = VDS
  workgroup = WORKGROUP
  server string = Vlad Data Store
  # Logging
  logging = syslog
  # Authentication
  security = user
  passdb backend = tdbsam
  map to guest = never
  # Name resolution: make sure \\NETBIOS_NAME\ works
  wins support = yes
  local master = yes
  domain master = yes
  preferred master = yes

[david]
  path = /samba/david
  browseable = no
  read only = no
  force create mode = 0660
  force directory mode = 2770
  valid users = david @admins

[everyone]
  path = /samba/everyone
  browseable = yes
  read only = no
  force create mode = 0660
  force directory mode = 2770
  valid users = @sambashare @admins
# SystemD
sudo systemctl restart smbd.service nmbd.service

Client configuration

# Install
sudo apt-get -y update
sudo apt-get -y install smbclient

# Access Samba shares
smbclient //samba.example.com/david -U david

# Mount directory
mkdir /samba
sudo mount_smbfs //[email protected]/david ./samba
net use X: \\samba.example.com\david

Misc

Change samba password with: sudo smbpasswd -a myUser

References

Clone this wiki locally