Samba file sharing

From Salix OS
Jump to: navigation, search

This page is about setting up file sharing with Samba. At the bottom of the page you'll find a sample smb.conf, which needs to be saved in /etc/samba appropriately.

Instructions

Here are the instructions I normally use to make your sambashare group. Make Your User a member of it. Create your samba password for your user

Throughout this How To replace for your purposes

 your_username replace with Your Real User Name
/home/your_username/Download replace with "The actual Dir you want to Share"
Workgroup  replace with "Your actual Workgroup Name"

You can cut and paste commands to a terminal to which you have su and become root Leave out all # ..As that is to indicate the Terminal prompt.

Install thunar-shares-plugin package if you are using Thunar File Manager.

Configuration Steps

These commands are done as the root user.

Become root user in a Terminal with the su command

This marks the named objects for automatic export to the environment of subsequently executed commands:

Code: Select all

   # export USERSHARES_DIR="/var/lib/samba/usershares"
   # export USERSHARES_GROUP="sambashare"


This creates the usershares directory in var/lib/samba:

Code: Select all

   # mkdir -p ${USERSHARES_DIR}


This makes the group sambashare:

Code: Select all

# groupadd ${USERSHARES_GROUP}


This changes the owner of the directory and group you just created to root:

Code: Select all

# chown root:${USERSHARES_GROUP} ${USERSHARES_DIR}


This changes the permissions of the usershares directory so that users in the group sambashare can read, write and execute files:

Code: Select all

   # chmod 01770 ${USERSHARES_DIR}


Make your user a member of the Group, replacing "your_username" with the name of your Real Actual username:

Code: Select all

   # usermod -a -G ${USERSHARES_GROUP} your_username


Check you are in the Group just created

Code: Select all

   # id your_username


Create a Password for your_username

Code: Select all

   # smbpasswd -a your_username


Enable your_username

Code: Select all

   #  smbpasswd -e your_username

Prepare the Samba Config (/etc/samba/smb.conf) Using your favorite text editor as root, create the file /etc/samba/smb.conf and Copy and Paste in the smb.conf below and save.

Then Restart Samba

Code: Select all

   # /etc/rc.d/rc.samba restart

or Reboot..

Sample config file

Sample Samba config (/etc/samba/smb.conf) used in this How To:'

   [global]
   Workgroup = Workgroup
   server string = %h server (Salix)
   panic action = /usr/share/samba/panic-action %d
   log file = /var/log/samba/log.%m
   usershare allow guests = Yes
   ####### Authentication #######
   security = user
   obey pam restrictions = Yes
   pam password change = Yes
   passwd program = /usr/bin/passwd %u
   passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
   unix password sync = Yes
   syslog = 0

   max log size = 1000
   name resolve order = bcast lmhosts host wins
   printcap name = cups
   dns proxy = No

   usershare max shares = 100
   map to guest = Bad User

   idmap config * : backend = tdb

   ########## Printing ##########
   # cupsys-client package.
   printing = cups
   printcap name = cups

   ########## Share Definitions ##########
   [homes]
   comment = Home Directories
   valid users = your_username
   create mask = 0700
   directory mask = 0700

   [printers]
   comment = All Printers
   path = /var/spool/samba
   create mask = 0700
   printable = Yes
   print ok = Yes
   browseable = No

   [print$]
   comment = Printer Drivers
   path = /var/lib/samba/printers

   [PUBLIC]
   path = /home/your_usernamel/Download
   valid users = your_username
   read only = No
   create mask = 0775