1.2 Configuring Samba (smb.conf)


Samba's configuration is stored in the smb.conf file, which usually resides in /etc/samba/smb.conf or /usr/local/samba/lib/smb.conf . You can either edit this file yourself or do it using one of the many graphical tools that are available, such as the Web-based interface SWAT, that is included with Samba.

1.2.1 Configuration file syntax

The smb.conf file uses the same syntax as the various old .ini files in Windows 3.1: Each file consists of various sections, which are started by putting the section name between brackets ([]) on a new line. Each contains zero or more key/value-pairs seperated by an equality sign (=). The file is just a plain-text file, so you can open and edit it with your favorite editing tool.

Each section in the smb.conf file represents a share on the Samba server. The section " global " is special, since it contains settings that apply to the whole Samba server and not to one share in particular.

Example 1.1 contains a very minimal smb.conf .

Example 1.1 A minimal smb.conf
  [global]   workgroup = WKG   netbios name = MYNAME   [share1]   path = /tmp   [share2]   path = /my_shared_folder   comment = Some random files  

1.2.2 Example Configuration

There are sample configuration files in the examples subdirectory in the distribution. It is suggested you read them carefully so you can see how the options go together in practice. See the man page for all the options. It might be worthwhile to start out with the smb.conf.default configuration file and adapt it to your needs. It contains plenty of comments.

The simplest useful configuration file would contain something like shown in Example 1.2.

Example 1.2 Another simple smb.conf File
  [global]   workgroup = MIDEARTH   [ homes ]   guest ok = no   read only = no  

This will allow connections by anyone with an account on the server, using either their login name or homes as the service name. (Note: The workgroup that Samba should appear in must also be set. The default workgroup name is WORKGROUP.)

Make sure you put the smb.conf file in the correct place.

For more information about security settings for the [homes] share please refer to Chapter 14, Securing Samba .

1.2.2.1 Test Your Config File with testparm

It's important to validate the contents of the smb.conf file using the testparm program. If testparm runs correctly, it will list the loaded services. If not, it will give an error message. Make sure it runs correctly and that the services look reasonable before proceeding. Enter the command:

 
 root# testparm /etc/samba/smb.conf 

Testparm will parse your configuration file and report any unknown parameters or incorrect syntax.

Always run testparm again whenever the smb.conf file is changed!

1.2.3 SWAT

SWAT is a Web-based interface that can be used to facilitate the configuration of Samba. SWAT might not be available in the Samba package that shipped with your platform, but in a separate package. Please read the SWAT manpage on compiling, installing and configuring SWAT from source.

To launch SWAT, just run your favorite Web browser and point it to http://localhost:901/ . Replace localhost with the name of the computer on which Samba is running if that is a different computer than your browser.

SWAT can be used from a browser on any IP-connected machine, but be aware that connecting from a remote machine leaves your connection open to password sniffing as passwords will be sent over the wire in the clear.

More information about SWAT can be found in Chapter 31, SWAT ” The Samba Web Administration Tool .



Official Samba-3 HOWTO and Reference Guide
The Official Samba-3 HOWTO and Reference Guide, 2nd Edition
ISBN: 0131882228
EAN: 2147483647
Year: 2005
Pages: 297

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net