Samba How-to

 

Text info
-----------

everything written with a $ sign at the beginning on its own line needs to be typed into the command line exactly as u see it
for example

$ cd/etc/


Background Info
----------------

samba is a file sharing server utility for linux that will work with windoze and linux computers. It is fairly easy to set up, and very
useful when u have got it going! :P Samba is much more stable than the windoze equivalent ie it dosnt crash as much! Samba can also be used as a pdc server
for roaming profiles etc. For all you people that dont know what pdc means it is a Primary Domain Controller and can offer your network a lot but i'm
not going into that here but i may write a tutorial in the future about it.

Installing
-----------
You can get samba from www.samba.org u need to d/l this file unless there is a newer version by then. (samba-2.0.6.tar.gz)

u need to unpack this file like so

$ tar -zxvf samba-2.0.6.tar.gz

If you didnt have any errors this should of unpacked into a dir called samba-2.0.6

You now ned to make the rpms

$ cd samba-2.0.6
$ su
$ chown -R root:root samba-2.0.6
$ cd samba-2.0.6/packaging/RedHat
$ sh makerpms.sh

that should then take a little time whilst it builds the rpms. You may need to swap the pacakge dir for wherever u have put urs.
When the rpms have built these files will have been made

/usr/src/redhat/RPMS/i386/samba-2.0.6-i386.rpm
/usr/src/redhat/SRPMS/samba-2.0.6-src.rpm

or something very similiar but you should be able to pin-point it because the name will have samba in it.

now you need to install samba.

$ # rpm -Uvh /usr/src/redhat/RPMS/i386/samba-2.0.6*.i386.rpm

yet again this may take a little time you may also need to change the dir where the samba files are put.

New User and Group
--------------------#

Samba uses share level security so we need to make a guest account for samba to run on.

1) make a group called smb

2)create the user smbuser the home directory should be /home/public

make sure u disable login on the smbuser account as no-one will be logging in on it.

Directory Configuration and Making
------------------------------------

You should already have a directory /home/public as you made it when u made the smbuser a minute ago. This dir will be owned by the group smb and the user
smb. Everyone will need to have read and write access to this dir so we set the permissions like this.

$ chown smbuser:smb /home/public
$ chmod 2777 /home/public

now ever file that gets created in /home/public will be owned by smb

now we need to make a data directory this will only be accesible by the people in the smb group.

$ mkdir /home/samba
$ chown smbuser:smb /home/samba
$ chmod 2770 /home/samba

$ mkdir /home/samba/data
$ chown smbuser:smb /home/samba/data
$ chmod 2770 /home/samba/data

if you look at these commands you will see that anything created in the data directory will be owned by the group smb.
As i want access to the data directory i add myself to the smb group.


SWAT - web-based admin for samba
----------------------------------

you can d/l swat from http://rpmfind.net just search for swat.
Swat lets u access a webpage that runs on port 901 it lets you change all the settings to do with samba.

When you have installed the rpm check in your /etc/inetd.conf file for a line that looks similiar to this

swat stream tcp nowait.400 root /usr/sbin/swat swat

You can change the line in your inted.conf file so that you can have tcp wrappers protecting swat, but i havent gone into this detail here.


Configuring Samba
------------------

Now that you have installed and configured samba and swat you need to edit your smb.conf file

Your smb.conf file maybe in /etc/smb.conf or /etc/samba/smb.conf, you need to open it up in an editor and copy this into it removing all the old data in there.

# Samba config file created using SWAT
# from bart (192.168.0.2)
# Date: 1999/01/16 15:57:15

# Global parameters
workgroup = SIMPSONS
server string = Samba SMB Server
nterfaces = 192.168.0.1/24 127.0.0.1/24
bind interfaces only = No
security = SHARE
log file = /var/log/samba/log.%m
max log size = 50
read bmpx = No
time server = Yes
socket options = TCP_NODELAY
os level = 65
preferred master = Yes
dns proxy = No
wins support = Yes
guest account = smbuser
hide dot files = No

[public]
comment = Public
path = /home/public
read only = No
create mask = 0664
directory mask = 0775
guest ok = Yes

[data]
comment = Data
path = /home/samba/data
read only = No
create mask = 0660
directory mask = 0770
guest ok = Yes

you need to make approiate changes in here for your network like changing the server name and workgroup.

Starting samba
----------------

You can either start samba from swat or the command line, if you are going to start samba from swat you may need to restart samba so it will read you
new config file, go to the status page in swat and select the relevant option. If you want to start samba from the command line type this in

$ /etc/rc.d/init.d/smb stop
$ /etc/rc.d/init.d/smb start

If you didnt see any error messages then everything should be running fine.

Finished
---------

Thank-you for reading this tutorial and i hope you found it useful.

 

Credits:

Author: m0ltenfubar 17/2/2002
Legion2000 Security Research 1996 - 2002
Website: www.legion2000.uni.cc
contact: legion2000-staff@hushmail.com