Samba on FreeBSD 7

Prerequisites:

FreeBSD (Base + Autoconf, Automake, Bash and GCC)

Overview:
 Step #1 - Download, Compile and Install Samba from FreeBSD Ports
 Step #2 - Basic Configuration
 Step #3 - Additional Help and References

Step #1

Samba – SMB/CIFS interoperability between Linux/Unix servers and Windows-based clients

Home: 

 http://www.samba.org

# Download (Notes: Users behind a Proxy Server should read this and users without Internet but have a CDRom read this.)
# Download and Install from FreeBSD Ports Collection
cd /usr/ports/net/samba3


#
 Compile
make install

 

Step #2

Basic Configuration

 
  1. When Samba was installed, it created a default configuration file you can copy to get started:
     

    cp /usr/local/etc/smb.conf.sample /usr/local/etc/smb.conf

    vi /usr/local/etc/smb.conf


     
  2. Item: 'workgroup'

    Change from "MYGROUP" to whatever the name your workgroup is.

    example:

     

    workgroup = YourWorkgroup
    remote announce = 192.168.0.255/YourWorkgroup


     
  3. Item: 'server string'

    Change the server string to whatever is appropriate. Here are some possibilities:

     
    %h Samba Server
    %h-the-FreeBSD-Samba-Server
    %h Samba
    %h_Samba_File_Server_1
     
    '%h' is a variable for the name of the Host computer that Samba is running on.

     
  4. Item: 'log file'

    The default line is:
     
    log file = /var/log/samba/log.%m
    The %m is a variable for the client logging in. You can use the default naming convention, or perhaps something like this:

     
    log file = /var/log/Samba-%m.log

     
  5. Set up the users so that they cannot obliterate their configuration files.  The first section is:

    Go down until you see:

    ========================== Share Definitions ==========================
    [homes]
       comment = Homes Directories
       browseable = no
       writable = yes
     
    Change this to:

     
    [homes]
       comment = Home directory for %u on %h
       browseable = no
       writable = yes
       path = /usr/home/%u/Docs
       valid users = %S
     

     
  6. Let's do the public section.  Just below the commented out section called [public] (just before the '# Other examples' section), let's add a public directory that can be read from and written to by all users:

     
    # A publicly accessible directory, that can be read from
    # or written to by all valid users.
    [public]
       comment = %h Shared Public Directory
       path = /usr/home/samba/public
       force directory mode = 0777
       force create mode = 0777
       force group = nobody
       force user = nobody
       public = yes
       writeable = yes
       read only = no
     
    Save this file and exit.


     
  7. Now let's test the file for typos and other errors:
     
    /usr/local/bin/testparm | more
    If you don't see any error messages, then it's good to go.

     
  8. Next, let's create those directories that we referenced just a bit ago:

     
    cd /usr/home

    mkdir samba

    cd samba

    mkdir public

    cd public

     
  9. Reboot the computer:
     

    shutdown -r now

  10. CREATE ACCOUNTS ON FREEBSD FOR WINDOWS USERS
           
    Each Samba user must be added to 2 user databases:
                The first is the FreeBSD OS database
                The second is the Samba user database.

    adduser -v
    Username: John
    Full name: John Doe
    Uid (Leave empty for default):
    Login group [John]:
    Login group is Linda. Invite Linda into other groups? []:
    Login class [default]:
    Shell (sh csh tcsh bash nologin) [sh]: bash
    Home directory [/home/Linda]:
    Use password-based authentication? [yes]:
    Use an empty password? (yes/no) [no]:
    Use a random password? (yes/no) [no]:
    Enter password:
    Enter password again:

    Lock out the account after creation? [no]:
    Username : John
    Password : *****
    Full Name : John Doe
    Uid : 1004
    Class :
    Groups : John
    Home : /home/John
    Shell : /usr/local/bin/bash
    Locked : no
    OK? (yes/no): yes
    adduser: INFO: Successfully added (John) to the user database.
    Add another user? (yes/no): no
    Goodbye!


     
  11. CREATE ACCOUNTS ON SAMBA FOR WINDOWS USERS

    smbpasswd -a John

    New SMB password:
    Retype new SMB password:
    Repeat the 'smbpasswd -a user' command for all of your Samba users



     
  12. SET SAMBA SO THAT IT LOADS ON BOOT UP
    We will need to add a line in this file so that Samba is run when booting up.
    vi /etc/rc.conf

    samba_enable="YES"

    Save the file and exit:



     

  13. SET PERMISSIONS FOR SAMBA SHARED DIRECTORIES
    Since we are allowing anyone to do anything in the public directory, set file permissions:

    cd /usr/home/samba

chmod u=rwx public

To give Read, Write and execute permissions to the members of the Group, enter:
 

chmod g=rwx public

To give Read, Write and execute permissions to all Others, enter:
 

chmod o=rwx public

Create the users' 'Docs' directories:
 

cd /usr/home

ls -lt

Looking at the list, you should see the names of the users that you set up.  For each user, we will now create a 'Docs' directory.  Substitute each of your users for 'username' in the following:
 

mkdir John/Docs

Now since we created all these 'Docs' directories as 'root', let's give ownership to the user.  For each user ('username'), do the following:
 

chown John John/Docs
 

Reboot and Test:

shutdown -r now

Go to a Windows computer and double-click on 'Network-Neighborhood'.  You should be able to navigate to your new Samba server!

Or try clicking "Start" then "Run" on your Windows computer and typing:
    \\YourFreeBSDServerIP
and click "Ok"


 

 

Step #3

Additional Help and References

 Thank you for these sites:
http://www.us-webmasters.com/FreeBSD/Install/Samba/
http://www.freebsddiary.org/samba.php
http://www.csua.berkeley.edu/~ranga/notes/freebsd_samba.html
 and of course always check here:
http://us2.samba.org/samba/