Project

General

Profile

Support #848

Updated by Daniel Curtis over 7 years ago

{{>toc}} 

 This is a guide for setting up two samba shares on FreeBSD 10; one guest share that is visible by everyone, and another share that must be authenticated. 

 h2. Prepare the Environment 

 * Make sure the system is up to date: 
 <pre> 
 pkg update && pkg upgrade 
 </pre> 

 h2. Install Samba 

 * Install samba4: 
 <pre> 
 pkg install samba43 
 </pre> 

 * Edit the samba config: 
 <pre> 
 vi /usr/local/etc/smb4.conf 
 </pre> 
 #* And add/edit the following: 
 <pre> 
 [global] 
 workgroup = WORKGROUP 
 server string = Samba Server v %v 
 netbios name = FileServer 
 wins support = Yes 
 security = user 
 passdb backend = tdbsam 
 </pre> 

 * Start and enable samba and winbind at boot: 
 <pre> 
 echo 'samba_server_enable="YES"' >> /etc/rc.conf 
 service samba_server start 
 </pre> 

 h3. Authenticated Share 

 * Add the user bob: 
 <pre> 
 adduser 
 </pre> 

 * Add the samba user bob: 
 <pre> 
 smbpasswd -a bob 
 </pre> 

 * Make the /var/privatedownloads folder: 
 <pre> 
 mkdir /var/privatedownloads 
 </pre> 

 * Change the ownership of the privatedownloads folder: 
 <pre> 
 chown bob /var/privatedownloads 
 </pre> 

 * Edit the samba config: 
 <pre> 
 vi /usr/local/etc/smb4.conf 
 </pre> 
 #* And add the following to the end of the file: 
 <pre> 
 # Share /var/privatedownloads accessible only to 'bob' user 
 [privatedownloads] 
 path = /var/privatedownloads 
 valid users = bob 
 writable    = yes 
 browsable = yes 
 read only = no 
 guest ok = no 
 public = no 
 create mask = 0666 
 directory mask = 0755 
 </pre> 

 * Restart samba: 
 <pre> 
 service samba_server restart 
 </pre> 

 h3. Read-Only Guest Share 

 * Make the /var/downloads folder: 
 <pre> 
 mkdir /var/downloads 
 </pre> 

 * Change the ownership of the ownloads folder: 
 <pre> 
 chown bob /var/downloads 
 </pre> 

 * Edit the samba config: 
 <pre> 
 vi /usr/local/etc/smb4.conf 
 </pre> 
 #* And add the following to the end of the file: 
 <pre> 
 # Share /var/downloads accessible to everyone as read-only 
 [downloads] 
 path = /var/downloads 
 writable    = no 
 browsable = yes 
 read only = yes 
 guest ok = yes 
 public = yes 
 directory mask = 0755 
 </pre> 

 * Restart samba: 
 <pre> 
 service samba_server restart 
 </pre> 

 h2. Resources 

 * https://www.freebsd.org/doc/handbook/network-samba.html 
 * http://scratching.psybermonkey.net/2010/10/freebsd-quick-setup-of-samba-file.html

Back