Samba Done Easy!
BACK
Here is the straight cut how-to do a Samba install configuration. This was done on a Celeron 266MHz machine with 128MB of SDRAM. I
installed Red Hat 7.2 on a 30gig Western Digital Drive and with Samba version 2.2.3a. Once I got this baby going I created a share called
MP3 and copied 5 gigs of mp3s that I had accumulated over a period of 6 months. Now all out through my network I can access these mp3s on
any Windows and Native Linux system on my network. One big advantage about Samba is that it runs clean, lean, and mean compare to a
Windows machine with a resource GUI hog! Not to forget, it's all free!!!!! Now how can you beat that?
Note! - This is assuming you have a Linux Box on a network with an IP address establish (e.g - 192.168.0.X). This has worked
with Caldera and Redhat 5 and up. Do all this at your own risk! I would recommend you trying it out in a test environment if you plan on
using this in a work environment. I must admit that this how-to gives no regards to high level security. With that said, if you
need a tighter secured configuration, search elsewhere.
Step 1
Click on over to http://www.samba.org and grab the latest Samba tarball and put it in a directory where you can
access it and untar this bad boy for install. Once downloaded, you should be able to simply run as root:
tar -vxzf samba-latest.tar.gz (press enter)
After running this, you should now have a folder called samba-2.2.x in the same directory where you originally downloaded the tarred file.
By the way, the x in the samba-2.2.x could be anything. As I write this the current download version is samba-2.2.3a. This is working well!
Step 2
You now need to change into the samba-2.2.x directory. Once in this directory, go into the source directory and this is where
we will
get ready to run the configure script. This jewel will tailor itself to your system. To do this, you must be root and type this:
./configure (press enter)
After awhile of the script rumping through your system, you will finally be brought back to the command line (after several minutes. Took mine about 10 minutes).
Here at this point you should
fairly see all positive output about your systems support toward Samba. One important dependency is having a gcc complier. In my experience
with this is all users will have a 95% success rate of being able to install Samba. If there was problems while running the configure
script, you will see the last view lines complaining with a single word ERROR! That
one will not be hard to miss. Hopefully you will not see this and
you will be able to continue. Still as root, we need to run:
make (press enter)
This is building the Samba binaries to allow us to do the actual install. This process could take awhile, all according to your system CPU
and memory. Once done, you will need to run one last command:
make install (press enter)
Again, this could take some time, so be patient as it does its thing!
Step 3
Now you need to change into the directory where Samba lives. You can do this by doing:
cd /usr/local/samba (press enter)
You will now be in the directory where you can access the the lib directory. Let's change into that directory. Do this by:
cd lib (press enter)
We are now ready to do an important step. We are about to create the smb.conf configuration file using your favorite text
editor (PICO rules!!!).
This is where all the shares are defined. Below is a sample configuration file that you can use. The only thing you need to do is
substitute your own machine name and Workgroup name.
#smb.conf
#
[global]
;let's set the server name
netbios name = YOURSERVER
;let's set the workgroup membership
workgroup = YOURWORKGROUP
;setting Samba to authenticate in user mode security
security = user
NOTE! Here at this point in the configuration file, we should temporarily exit and save our progress as the file name smb.conf. We now need to
consider where we want to share our public shares. What I did was create a user account simply named Share.
Still as root, issue this command:
adduser share (press enter)
I will now have a central location where to share public shares and be on a partition that is large enough to where I want have
the fear I'll run out of hard drive space. Once you create the account you will now need to set the password and the read and execute
permissions correctly so we can share inside the share account. Issue this command:
passwd share (press enter and enter password)
After entering password retype it to confirm it. Now let's set the permission on the account:
chmod 755 /home/share (press enter)
We now are ready to edit futher on our configuration file. You should still be in the /usr/local/samba/lib directory. If not,
you need to change back into that directory and let's open smb.conf file with our favorite text editor. Our first entry was
setting up the server name and the workgroup allowed to access the Samba shares. We are now actually going to set up the first share we are
going to share. Just copy this:
;This is the name of your share.
[share1]
;The name that will appear when you view the share
comment = Share1
;The direct path to the share
path = /home/share/share1
;Defining the allowed group to access the share
valid users = @share
;Enforcing file locking?
locking = no
;Creation Permission on files
create mode = 0777
;Creation Permission on directories
directory mode = 0777
Now we will setup the user's home directories. This will allow your users that have accounts on your Samba server to access the
directories that were created for them, when their accounts were created. This would be a good time to point out the importance of having
the correct users setup on your system. Assuring you of their ability to access the shares they have permissions to. Giving the example of
two user accounts; user1 and user2. By verifying the accounts:
ls /home (press enter)
You should see the listings of the accounts there. If you don't, you should create them by running the adduser command
as root and setting the passwords for the accounts with the passwd command. Now we will edit the smb.conf file
to include the user accounts:
;Home directories.
[home]
comment = User's home directories
path = %H
writeable = yes
valid users = %S
create mode = 0777
directory mode = 0777
locking = no
The whole smb.conf file should look like this:
#smb.conf
#
[global]
;let's set the server name
netbios name = YOURSERVER
;let's set the workgroup membership
workgroup = YOURWORKGROUP
;setting Samba to authenticate in user mode security
security = user
;This is the name of your share.
[share1]
;The name that will appear when you view the share
comment = Share1
;The direct path to the share
path = /home/share/share1
;Defining the allowed group to access the share
valid users = @share
;Enforcing file locking?
locking = no
;Creation Permission on files
create mode = 0777
;Creation Permission on directories
directory mode = 0777
;Home directories.
[home]
comment = User's home directories
path = %H
writeable = yes
valid users = %S
create mode = 0777
directory mode = 0777
locking = no
Now we need to do a little mopping up. Let's go back and actually create our share in the /home/share account. Still as
root, we will enter into that directory and create a directory called share1.
mkdir share1 (press enter)
We should now set the correct permissions.
chmod 775 /home/share/share1 (press enter)
Now we need to change the group membership on the directory by issuing this command:
chgrp share /home/share/share1 (press enter)
We should now and create the locks directory in the /usr/local/samba/var directory. Just issue this command:
mkdir /usr/local/samba/var/locks (press enter)
Now lets add our users to the group share by manually editing the /etc/group file. You will need to use your
favorite text editor and find the correct group. In this case, ours will be share. It should look like similar to this:
share::502:
We will just add to the end of this line the users whom we want to include in the group, which will be user1 and
user2 . Our new line should look like this:
share::502:user1,user2
Now save and exit and this will wrap up a great deal of getting Samba up and running! We are now ready to run the testparm
command on the newly created smb.conf file. To do this, you need to enter this at the command line:
/usr/local/samba/bin/testparm /usr/local/samba/lib/smb.conf (press enter)
If all goes well, you should see a message that all services loaded correctly or "OK". Now assuming everything is fine, let's get Samba
started. There is two ways in getting Samba started. You can have it automatically begin when you start up the server from a reboot or a
cold start or you can start the server manually by the command line. In my experience, you'll want to do the manual start. Not going into
details about why you should start Samba manually, it is written in several newsgroups that running the two , nmbd and
smbd as daemons increases response time and seems to not want to crash and burn. Not saying that this is a common trait of
Samba, but it did happen with me one time. And one time only! To start Samba, issue this command!
cd /usr/local/samba/bin (press enter)
Now do this: ./nmbd -D ; ./smbd -D (press enter)
Samba should now be on line!
Now get on a Windows machine and log onto the Samba server with the username and password that you created on the Samba server. This is
assuming you have a Windows client up and running on the network using the SMB protocol. By browsing to your Network Neighborhood Icon
on your desktop, you should see a new machine listed as Share1. Now on to step 4!
Step 4
At this point you might be smiling from ear to ear. Until you try and go a little futher into the share and notice that you'll be greeted
with a username log on prompt. Even worse, it's possible that if your on a Windows ME client, you won't even see the Samba Server or the share at all. The
reason for this is because of encrypted passwords. By default the Samba server comes with encrypted passwords turned off and Windows 95 and up only sends encrypted
passwords across the network.
There is a solution! We are going to get our current /etc/passwd file transfered to the correct Samba directory. Then we are going to setup a Windows
client to only do plain-text passwords and have the Samba server catch these passwords.
This works well if you only have a few clients. Obviously, if you have 100+ clients, this is not a solution, but the scope of this help
document is to get Samba up and running quick!
The first thing is to use a script that came with Samba when we untarred it. It is called "mksmbpasswd.sh". To use this you need to go to location where we
untarred the samba tarball (e.g.- samba-latest.tar.gz). In that same location is the actual directory that was created which in this example was
samba-2.2.X. In this directory there will be a directory called source. In this source directory is a directory called
scripts. In this directory, this is where you will find the mksmbpasswd.sh script that will perform the task of getting the
/etc/passwd file transferred to the /usr/local/samba/private directory. This is where will save the passwd file to the new name
smbpasswd. We need to copy the script to the /bin folder by:
cp /wherever/directory/samba-2.2.x/source/script/mksmbpasswd.sh /bin (press enter).
After that we need to make this script executable so that the script will be able to perform the task of exporting the /etc/passwd file to the correct
location. You will need to run the command:
chmod +x /bin/mksmbpasswd.sh (press enter)
Now once we have the script copied over to the /bin directory and the script executable, we need to put it to work. Here is the magic command:
cat /etc/passwd | mksmbpasswd.sh > /usr/local/samba/private/smbpasswd (press enter)
That should be the magic! If no error occurred, then you've successfully copied the /etc/passwd file to the /usr/local/samba/private
directory by the name of smbpasswd. Verify this by running your list command:
ls /usr/local/samba/private (press enter)
You should see a file listed as smbpasswd. If so, then we are ready to modify our smb.conf configuration file so that encrypt passwords
is turned off and the update encrypted passwords is on. These settings will allow a Windows Client that is passing plain-text passwords to the Samba server to be
updated in the smbpasswd file that we just created. More on getting a Windows Client to pass plain-text passwords will soon follow in this reading.
Use your favorite text editor to edit the /usr/local/samba/lib/smb.conf file. The part in the smb.conf file that you should edit is the
the [global] section. Below is an example on how your [global] section should look:
[global]
netbios name = YOURSERVER
workgroup = YOURWORKGROUP
security = user
update encrypted = yes
encrypt passwords = no
Once you have the smb.conf file edited to the above, You should now restart your server by restarting the daemons that make up the Samba Server. To do
this simply type this below on the command line:
/usr/local/samba/bin/nmbd -D ; /usr/local/samba/bin/smbd -D (press enter)
To save you some time in the future, I would recommend making a executable file that will start or restart the server when you need to. This can be accomplished by
opening a new file with you favorite text editor. I use Pico to do this. I created a file in the root directory called on. Once I have this newly
created file opened, I type out the two lines that it takes to start the the two daemons. Here is the line:
/usr/local/samba/bin/nmbd -D ;
/usr/local/samba/bin/smbd -D
Once this is typed out save your file in the /bin directory and chmod it so that it is executable. Just run:
chmod a+x on
Now you have an easy way of getting your Samba Server up and running by simply typing ./on. Wow! You didn't know you could program, eh? Moving on...
Next thing we need to do is do some registry editing on the Windows Client. This is assuming your Windows client is 95 and up. This
registry edit doesn't work on Windows NT or 2000. In this case, you need to do this on a Windows 95 or 98 client. By going to the the
Start-->Run--> and typing in the Run command line--> regedit. You will be greeted with the Registry editing utility. Be careful here,
as you've probably already heard that registry edits could cripple your system. This is all very true! I will direct you to the exact
location that you need to be.
In the registry editor locate the key:
HKEY_LOCAL_MACHINE--> System--> CurrentControlSet--> Services--> VxD--> VNETSUP
Here we will create a new DWORD value by selecting on the top menu:
Edit--> New--> DWORD value
You will now notice to the right of the "split" window, a new entry where we will be able to type the name of the DWORD value. Type it just like this:
EnablePlainTextPassword
Now we need to right click on our new entry and modify the value entry from "0" to "1". You will now need to exit out of the registry editor and restart your
computer so the changes will take effect. At this point your Windows machine will be sending "Plain Text Passwords" to the Samba Server. After you feel that you
have all the clients added to your smbpasswd file, you will now be ready to test to see if you can enter into the share defined by your
smb.conf file that we created. By logging in as one of the Samba users go into the Network Neighboorhood or My Network Places in your Windows machine.
You should see, hopefully the shares. Once you have successfully seen and entered into the share, you should try to copy or write inside the share with the account
if it should have the correct permissions. I all is satisfactory, it's time to wrap up the Samba side by making one last edit to our smb.conf file. By
using our favorite text editor we should open the smb.conf file and change the [global] section by reversing the "yes" and "no" of the
update encrypted and the encrypt passwords. Your newly edited section should look like this:
[global]
netbios name = YOURSERVER
workgroup = YOURWORKGROUP
security = user
update encrypted = no
encrypt passwords = yes
Once done, save and exit out of the smb.conf file and restart your Samba server by rerunning the daemons with your new on executable.
This should be in the /bin directory and by simply typing ./on at the command line, you should be getting closer to sharing files with
Samba! We hope :-)
Now let's wrap up the Windows by setting the client you had set up to pass plain-text passwords back to sending passwords encrypted. By going to the the
Start-->Run--> and typing in the Run command line--> regedit. You will be greeted with the Registry editing utility again. As I have said before, Be
careful here. In the registry editor locate the key:
HKEY_LOCAL_MACHINE--> System--> CurrentControlSet--> Services--> VxD--> VNETSUP
Now find the DWORD in the right pane called "EnablePlainTextPassword". Once located, simply right-click on this entry and now click "delete". Once
this is done, you should exit out of the registry editor and restart your Windows client so that the registry edit can take effect. Now I must say with aching
finger honor, this "quick" howto is over!
Please let me know if this worked for. You can email me to let me know your success or comments of this writing.
I'm always intrested in what you have to say! Good luck with your venture in using Samba!
Written by: Jason L Woodruff -2002 March