Monday, October 22, 2007

Installing Samba on Linux

Why use Samba
Free software and is a way of getting windows like shares on a UNIX machine. Useful for using on the internet network card of the CCP14 Linux server.

Samba for UNIX/Linux :
At http://www.samba.org
At http://samba.mirror.ac.uk/samba/samba.html


Where to get Samba
Samba for UNIX/Linux :
At http://www.samba.orgl
At http://samba.mirror.ac.uk/samba/samba.html


Compiling and Installing Samba on Linux
---------------------------------------
- To extract the install file, grab the latest (9th April 2003) tar.gz file from the Samba website and type gzip -d < samba-2.2.8a.tar.gz | tar xvof -

- Go into the samba-2.2.8a/source subdirectory and then do:
./configure
make
Then as root: make install (this installs into /usr/local/samba)
done!

- To have samba start on bootup, put the following in the /etc/rc.d/rc.local file:
#--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
#--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+

#Start samba smbd nmbd

echo "Starting samba smbd nmbd deamon - startup in /etc/rc.d/rc.local"
echo "config file for samba in /usr/local/samba/lib/"

/usr/local/samba/bin/smbd -D
/usr/local/samba/bin/nmbd -D


Now for the more tricky part of configuration.



Configuring Samba on the internal network
-----------------------------------------
Config files are in /usr/local/samba/lib

The trick is to only have samba working on the internal network card, not the external one. This is done using the bind interfaces only and interfaces directives. Don't forget to add the encrypt passwords = yes or windows won't be able to log in and give cryptic responses.

Samba can be quite neurotic so you may have to stick with it. Much of the pain is due to how Windows PCs will want to talk with it and using or not using password encription.


- SAMBA Documentation including troubleshooting (including Correct passwords being rejected (encryption).): http://www.ast.cam.ac.uk/~rgm/cirsi/samba/samba.html

- Another reason why Samba can refuse connection is that your local Windows password does not match the password created by smbpasswd. Please check this out, it can save you a world of pain. It does not hurt to do the passwords again just in case

- If encrypt passwords = yes is "not" used.

- SAMBA and Windows 98 : http://www.amherst.edu/~pdchapin/access/win98samba.html
For security reasons, Windows 98 will normally not allow you to send plain text passwords. It sends only encrypted passwords. However, (the old) Samba servers require plain text passwords, so you cannot connect to Samba servers unless you change a registry entry to enable plain text passwords. To enable plain-text passwords, add the Registry entry EnablePlainTextPassword (reg Dword) 1 in the following Registry location: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\VxD\Vnetsup


- SAMBA and Windows 98 and Windows NT4 (service pack 3 or later) : http://www.med.nyu.edu/rcr/win98NTsamba.html
For security reasons, Windows 98/NT4 will normally not allow you to send plain text passwords. It sends only encrypted passwords. However, Samba servers require plain text passwords, so you cannot connect to Samba servers unless you change a registry entry to enable plain text passwords.

To enable plain-text passwords:

1. Start->Run.
2. Type regedit.
3. Add the DWORD value to the Registry entry EnablePlainTextPassword (reg Dword) 1 in the following Registry location:
Win98: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\VxD\VNETSETUP
WinNT: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Rdr\Parameters

NOTE: In the string "EnablePlainTextPassword"there are no spaces and case is important.



Config File
-----------
Note: The last stuff in global is telling the Samba-Server toi be subordinate to Windows servers.

[global]
workgroup = IMG
server string = CCP14 BBK Interal Data Server
hosts allow = 193.61.
hosts deny = ALL
bind interfaces only = True
interfaces = eth0 193.61.35.93
encrypt passwords = yes
domain logons = yes
username map = /usr/local/samba/lib/users.map
smb passwd file = /etc/smbpasswd
local master = no
domain master = no
preferred master = no
os level = 0

[tmp]
comment = Tmp Iso Image Area
path = /tmp/isos
browseable = yes
public = yes
guest ok = yes
read only = yes

[dataarea]
comment = Blah for Simon Jacques
path = /web_disc/jacques/dldata
browseable = yes
public = yes
read only = yes
valid users = blahuser
invalid users = root bin daemon nobody named sys tty disk mem kmem users

[homes]
comment = Home Directories
browseable = no
read only = no
valid users = jacques ccp14
invalid users = root bin daemon nobody named sys tty disk mem kmem



Adding users into Samba
-----------------------
Before doing this, do:

vi /etc/smbpasswd so as to create an empty Samba password file otherwise smbpasswd may not be happy.

As root, use : /usr/local/samba/bin/smbpasswd with the -a option

e.g.,

/usr/local/samba/bin/smbpasswd -a user1



Testing Samba
-------------
See if things are working from the UNIX point of view:

/usr/local/samba/bin/smbclient -L mill.cryst.bbk.ac.uk

From a Windows DOS prompt:

net use g: \\mill\tmp

smbclient copying from a user account from another UNIX machine:

smbclient \\\\computername\\username -Uusername



Killing and Restarting Samba
-----------------------------
Config files are in /usr/local/samba/lib


killall -9 smbd
killall -9 nmbd

/usr/local/samba/bin/smbd -D -s /usr/local/samba/lib/smb.conf
/usr/local/samba/bin/nmbd -D -s /usr/local/samba/lib/smb.conf
or


killall -9 smbd
killall -9 nmbd

/usr/local/samba/bin/smbd -D
/usr/local/samba/bin/nmbd -D
Or create a /usr/local/bin/restartsamba script (don't forget to chmod +x /usr/local/bin/restartsamba)


#! /bin/sh
#
# Kill and restart Samba
#
echo -n "Shutting down Samba: "
killall -9 smbd
killall -9 nmbd
echo -n "Restarting Samba "
/usr/local/samba/bin/smbd -D
/usr/local/samba/bin/nmbd -D
echo " done"

No comments:

Post a Comment