Typo
[linux_from_scratch_hints.git] / OLD / samba.txt
blobb7c51df8f5623fd945e42517d5e4130fe5f25cb0
1 TITLE:        Samba File and Print Server Hint
2 LFS VERSION:    3.0-RC1
3 AUTHOR:        Patrick Kirk < patrick@kirks.net >
6 Overview
9 Samba allows your Linux box to perform a number of functions that are
10 typically the preserve of Windows 2000 Server Edition, for example
11 acting as a Primary Domain Controller for a Win2k Domain, acting as a
12 Backup Domain controller or simply as a file server to share disk space
13 with Windows PCs in a safe and secure manner.  In all these capacities,
14 Samba can be expected to save a lot of license fees and be far more
15 secure than any alternative.
17 This hint is for setting up samba as a file and print server on machine
18 where security is important.  The emphasis is on security for the server
19 and ease of use for the users.  For example, I use these settings on the
20 machine that shares my ADSL connection.  
24 1. Installation
26 Samba can be downloaded from www.samba.org.  Its default installation
27 created a directory called samba in /usr/local and tidily puts all its
28 bits in there.  If like me you like to ne able to backup your system
29 configuration just by backing up /etc this needs to be changes.  Also,
30 to save messing around with editing your path, it is worth specifying
31 the executables go in /usr/local/bin and sbin as appropriate.
33 As root execute these commands:
35 cd /usr/src &&
36 tar xzvf samba*.tar.gz &&
37 mkdir -p /etc/samba  &&
38 mkdir -p /var/lock/samba  &&
39 cd samba-2.2.1a/source &&
40 /configure --prefix=/usr/local --bindir=/usr/local/bin \
41 --sbindir=/usr/local/sbin --libdir=/etc/samba --sysconfdir=/etc/samba \
42 --with-smbmount && make && make install 
44 2. Setting up sharing
46 In /etc/samba create a file called smb.conf and paste the following in:
48 [global]
49     workgroup = KIRKS.NET    # Put your own in here.
50     netbios name = ENTERPRISE    # The hostname for your machine
51     server string = %h server (Samba %v)
52     encrypt passwords = Yes
53     smb passwd file = /etc/samba/sambapasswd    #Easier backups
54     syslog = 0    #Level of logging to syslog.  Keep this low
55     max log size = 1000
56     log file = /var/log/samba/samba.log.%m # where to keep records
57     log level = 2    #Log interesting stuff only
58     # Performance tuning - this works.  RTFM before tweaking
59     socket options = IPTOS_LOWDELAY \ 
60     TCP_NODELAY SO_SNDBUF=4096 SO_RCVBUF=4096
61     dns proxy = No    #One tool for one job.  Use bind for DNS.
62     #Security
63     #These  entries are essential.
64     invalid users = root    
65     #Otherwise someone could attack the shares just by browsing 
66      # from your workstation
67     
68     # Specify the IP range of your LAN and the ethernet card used to
69     # access the LAN
70     # Leave the 127.0.0.1 entry there for diagnostics
71     interfaces = eth0 192.168.0.0/255.255.255.0 127.0.0.1/24 
72     # Even if a remote attacker decodes a password, he is still
73     # locked out 
74     bind interfaces only = yes
77 [homes]
78     # Allows users to store their data on the server
79     comment = Home Directories
80     read only = No
81     create mask = 0700
82     directory mask = 0700
83     browseable = Yes
84 [data]
85     # Create a folder for publicly shared resources like 
86     # databases, telephone lists, etc.
87         comment = Data Files and Backups
88     # You need to set his path.  Mine is...
89         path = /home/data
90         read only = No
91         create mask = 0775
92         directory mask = 0775
93         browseable = Yes
95 [system]
96     # Copy the i386 folder from the Win2k CD here. 
97     # Saves lots of time installing new drivers! 
98     # Any other other CDs you use a lot.
99     # 
100         comment = System and Installation Files
101     # You need to set his path.  Mine is...
102         path = /home/system
103         read only = No
104         create mask = 0775
105         directory mask = 0775
106         browseable = Yes
108 [printers]
109         comment = All Printers
110         path = /tmp
111         create mask = 0700
112         printable = Yes
113         browseable = No
115 # End of file
119 3. Setting up users
120 smbpasswd -a john adds john and prompts you for john's password.  Unless
121 you have lots of users, repeat this for each.  If you have too many for
122 this to be practical, configure SWAT which allows you to manage users
123 and groups from a remote web-browser.  SWAT is very easy to use but if
124 you need to use it there is detailed documentation including an O'Reilly
125 book in html format on http://sunsite.dk/samba/docs
127 4. Setting up client machines
128 Windows 2000 machines will now just work if the username on the machine
129 is the same as the account name you set up on the samba server.  If not
130 the same, then map network drives and take the option use the drive
131 under the name and password you set up on the server.
133 You might consider creating a batch file called login.bat in the startup
134 group of client boxes that goes as follows:
136 net use h: \\192.168.0.1\homes /persistent:no
138 net use i: \\192.168.0.1\data /persistent:no
140 net use j: \\192.168.0.1\system /persistent:no
142 5. Starting samba
143 Create a file in /etc/init.d called samba and paste the following in:
145 #!/bin/sh
146 # Begin /etc/init.d/samba
149 # Include the functions declared in the /etc/init.d/functions file
152 source /etc/init.d/functions
154 case "$1" in
155         start)
156                 echo -n "Starting Samba daemon..."
157                 loadproc /usr/local/sbin/nmbd
159                 echo -n "...Samba daemon started!"
160                 loadproc /usr/local/sbin/smbd
161                 ;;
163         stop)
164                 echo -n "Stopping Samba daemon!"
165                 killproc smbd
167                 echo -n "...Samba daemon stopped."
168                 killproc nmbd
169                 ;;
171         reload)
172         echo -n "Reloading Samba daemon configuration file..."
173                 reloadproc smbd
174         ireloadproc nmbd
175                 ;;
177         restart)
178                 $0 stop
179                 /usr/bin/sleep 1
180                 $0 start
181                 ;;
183         status)
184                 statusproc /usr/local/sbin/nmbd
185                 statusproc /usr/local/sbin/smbd
186                 ;;
188         *)
189                 echo "Usage: $0 {start|stop|reload|restart|status}"
190                 exit 1
191         ;;
193 esac
195 # End /etc/init.d/samba
197 To start samba, simply enter /etc/init.d/samba start
199 To have samba start every time your machine starts, run the following
200 command:
202 chmod 754 /etc/init.d/samba &&
204 ln -s  ../init.d/samba /etc/rc0.d/K400samba &&
206 ln -s  ../init.d/samba /etc/rc1.d/K400samba &&
208 ln -s  ../init.d/samba /etc/rc2.d/K400samba &&
210 ln -s  ../init.d/samba /etc/rc3.d/S600samba &&
212 ln -s  ../init.d/samba /etc/rc4.d/S600samba &&
214 ln -s  ../init.d/samba /etc/rc5.d/S600samba &&
216 ln -s  ../init.d/samba /etc/rc6.d/K400samba
219 6. The end
220 Congratulations.  You now have a fileserver set up that is safe, stable
221 and secure.