Setting up a Samba Server

This article deals with setting up a Samba server. With it you can share folders across the network, even with Windows computers.

= Installing the Samba Server =

Several Linux distributions now supply their own tools for configuring Samba in a simple way, and these are mentioned below. There are also distribution-independent tools to configure Samba: Webmin is a web-based configuration tool contained.
 * swat
 * SWAT is often provided in a separate package. Once installed, it listens on port 901, so you can access it at http://myservername.mydomain:901/. If that does not work, stop your firewall.
 * webmin
 * webmin

distribution-specific
To start installing the samba service, find out your distribution.

Debian
Open up a shell and type in: apt-get install samba It will ask you some basic questions about how to configure the server--most of the relevant information is found below. Don't get too scared, you may edit all of the options later in the /etc/samba/smb.conf file.

For a more in depth look at installing samba on a debian system, try Samba Server Setup in Debian.

Fedora
Fedora has a GUI-utility system-config-network that provides basic access to samba-configuration. Make sure that firewall rules do not disable samba traffic.

If samba was not already installed use: yum install samba

Mandriva
excecute (as root): urpmi drakwizard drakwizard

select samba

For more information on configuring samba for Mandriva Linux, please see the Mandriva KnowledgeBase

SUSE
Run sudo yast2 samba-server This will install samba if needed and allow you to configure it. You can find additional documentation at /usr/share/doc/packages/samba/examples/smb.conf.SuSE

Red Hat
There are three ways to configure the samba daemon in Red Hat Linux 9. "redhat-config-samba" is a graphical configuration client that is available (in Gnome) under hat|System Settings|Server Settings|Samba.

Generic
If your distribution does not allow you to configure samba shares, you will have to do it by editing configuration files. This is described here. However, it is less errorprone if you use your distribution's tools.

Configuration
The easiest samba server configuration is to share a folder: mv /etc/samba/smb.conf /etc/samba/smb-1.conf [global] security = share client lanman auth = Yes lanman auth = Yes [tmp] comment = Temporary file space path = /tmp read only = no 	public = yes
 * save your old samba configuration:
 * create a new file /etc/samba/smb.conf:
 * This will create a share tmp

Note: To avoid coming error message: "Server requested LANMAN password (share-level security) but 'client lanman auth' is disabled", need to add the last two options in [global] section.

/etc/init.d/smb restart Enter root's password: Domain=[TWEEDLEBURG] OS=[Unix] Server=[Samba 3.2.7-11.2.1-2080-SUSE-CODE11] Sharename      Type      Comment -            --- [...]         tmp             Disk [...] mount.cifs //192.168.0.2/tmp /mnt/smb
 * restart the samba service on your computer
 * check the share is available on its own computer:
 * 1) smbclient -L localhost
 * check the share is accessible on its own computer:
 * This will mount /public on the mountpoint /mnt/smb.

Firewall Configuration
The following ports will need to be allowed through your firewall to enable Samba connections. It follows a format of Port Number:Protocol. 445:tcp 139:tcp 138:udp 137:udp See www.iana.org for a list of common port numbers, names and their protocols.

Checking Shares
An easy way to check if your Samba shares are working properly from remote is to install the samba client software and use the smbclient tool in Linux or the net command in Windows. For instance, to view all of the available share information in Linux, simply type: smbclient -L hostname Where hostname can be any host on the network, even localhost. You can also provide a username to smbclient, like so: smbclient -L hostname -U username It will then prompt you for a password, you can enter none for anonymous access.

On Windows, issue net view \\hostname

= Mapping shares from Windows =

On Windows, you can connect your Linux/Samba shares from Network Neighbourhood or map them to a drive from Windows Explorer. Or you use this example batch script tested with Windows 98/2000/XP. Simply open up notepad, paste this text into the file, and save it as something like, "connect.bat." Be sure not to forget the ".bat" or the script will not work. After that, replace "\\yourServer\share /user:username" with the appropriate names. It will reconnect the share upon startup each time.

@echo off echo Connection Script.... echo -- echo. echo Disconnecting network share...(Z:) net use /delete z: echo Reconnecting network share...(Z:) echo Please enter password if prompted echo. net use z: \\yourServer\share /user:username echo. echo Script completed... pause

Here's a second script, this one written in VBScript, so it will only work on Windows 98SE/2000/XP. It is, however, much more reliable, a bit of fault tolerance built in to it. Once again, just change the appropriate names.

dim wshNetwork on error resume next set wshNetwork = CreateObject("WScript.Network") wshNetwork.MapNetworkDrive "Z:", "\\yourServer\share" if Err.number <> 0 then wscript.echo "Couldn't connect, sorry " & wshNetwork.userName end if

= See also =
 * NFS - sharing files over the network; Linux-Linux only
 * Interoperability - more topics on Linux-Windows coexistence
 * Samba - more on samba, including the client software
 * The SAMBA man page
 * http://www.samba.org/