Samba Server

Configuration

Configuration file for Samba server is /etc/samba/smb.conf Open it with your favorite text editor and let's edit. In the beginning of file (in global section) you'll see following: Code: smb.conf file

[global]

# workgroup = NT-Domain-Name or Workgroup-Name, eg: LINUX2
   workgroup = WORKGROUP
   netbios name = LINUXBOX

# server string is the equivalent of the NT Description field
   server string = Lets dance samba

# Security mode. Defines in which mode Samba will operate. Possible
# values are share, user, server, domain and ads. Most people will want
# user level security. See the HOWTO Collection for details.
   security = share

"Netbios name" is your computer name (usually same as your hostname). "Workgroup" is your workgroup (how strange, isn't it? :)). "Server string" is description of the samba server. Make security = share if you want to share files without password. Easy for making anonymous access.

  • Requiring Authentication For Your Samba Shares

If you are interested in requiring your remote users to log into the share and protecting it with a password, you should set an alias for guest. This is because Windows (XP Pro in my case at least) uses the username "Guest" as the default login with the share security level. Do this as follows:

guest account = local_user

The problem is that this will only work for authenticating 1 user. In my case, I only have 1 local account on my samba server, so it works for me. Hopefully someone will come along to edit this to allow for different user logins per share.

Make a particular directory for samba log files. And set maximum log size, because we don't want to be flooded with huge logs.

log file = /var/log/smb/samba.%m
max log size = 50

Now proceed in the file and find this part:

# Browser Control Options:
# set local master to no if you don't want Samba to become a master
# browser on your network. Otherwise the normal election rules apply
#   local master = yes

If you don't want windows users to blame you, change option local master to "no" and uncomment the line. With this option = yes your linux box and windows hosts will argue about local master browser rights on your LAN. Make this change:

local master = no

If you'd like to share your printers over samba (assuming your printers are running under a cups server), you need to add the following lines somewhere in the global section:

#added for remote printer use over samba
printcap name = cups
disable spoolss = Yes
show add printer wizard = No
printing = cups

This will require that the remote machines install the drivers for the printer locally. In the case of Windows machines, you will need to install the drivers first and then connect to the share over the network.

We're finished with global section of smb.conf file. Now proceed in the next chapter to see how to share directories. --Skeezer65134 12:07am, 27 June 2005 (CST)

Adding a Share

Sharing on Linux is simple as on Windows box. Just go to end of smb.conf file and add this:

Sharing directories with Samba

[public]
        comment = shared
        path = /mnt/public
        guest ok = yes
        browseable = yes

Make neccessary changes, where "comment" is your share comment, "path" is your shared directory path and "public" is your shared directory name. This will allow users on your network to connect to this share with access rights of user nobody.

If you are interested in using user authentication, you need to specify what users may access this share. Change the above to look like this:

Sharing directories with user access control with Samba

[public]
        comment = shared
        path = /mnt/public
        valid users = local_user
        guest ok = no
        browseable = yes

This will allow a remote machine to connect to the samba share by logging in as local_user and entering the correct password. Note that we use the 'guest account = local_user' above in the global configuration. Again, Windows will default to logging in as Guest, and you will not be able to chage this, so the above makes a nice work-around.

If you want to give write permissions to your samba users, just add writable = yes, as follows (make sure that permissions in those directories you are offering are right. If not, use chmod, of course):

[public]
        comment = shared
        path = /mnt/public
        valid users = local_user
        guest ok = no
        browseable = yes
        writable = yes

To add all local printers that connect via the CUPS server, add something like this:

[printers]
        comment = All Printers
        path = /var/spool/samba
        printer admin = root, local_user
        create mask = 0600
        guest ok = Yes
        printable = Yes
        use client driver = Yes
        browseable = No

This will list ALL of your local CUPS printers and list them based on their names and descriptions as defined in the CUPS configuration. Once again, the local machine connecting to the printer over samba will need to install the drivers first for it to work.

Don't forget you need to start your Samba server before you can set the user's Samba password. Code: Starting Samba

#/etc/init.d/samba start
 * Caching service dependencies ...                                       [ ok ]
 * samba -> start: smbd ...                                               [ ok ]
 * samba -> start: nmbd ...                                               [ ok ]

Adding a Valid User

For user access control, please note that you MUST specify a password for local_user using smbpasswd. The reason being that the user must also exist in /etc/samba/smbusers AND be a valid user on the computer running the samba server for Samba to have enough information to go through with authentication.

Setting samba user passwords

#smbpasswd -a local_user
New SMB password: <type password>
Reenter smb password: <type password again>
Added user local_user.

/etc/samba/smbusers

local_user = local_user

Note that the second name you enter can be a separate alias for local_user to log in to the samba share. More clearly, the name to the right of the = can be anything and will be used to log into the samba share. This must match the "valid user" statement in the share's definition.

Starting Samba on Boot

Adding Samba to default runlevel

rc-update add samba default

http://gentoo-wiki.com/HOWTO_Setup_Samba »

Page Comments (Click to edit)

Design by N.Design Studio, adapted by solidGone.org (version 1.0.0)
Powered by pmwiki-2.2.0-beta65