How to Configure Samba on RedHat Linux

Reply

Join Date: Feb 2002
Posts: 12,043
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 129
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is offline Offline
The Queen of DaniWeb

How to Configure Samba on RedHat Linux

 
0
  #1
Nov 16th, 2003
What's Samba?

Samba allows linux computers to share files and printers across a network connection. By using its SMB protocol, your linux box can appear in Windows Network Neighborhood or My Network Places just like any other windows machine. You can share files this way, as well as printers. By using samba on my home network, for example, my Windows machines have access to a printer directly hooked up to my Linux box, and my Linux box has access to a printer directly hooked up to one of my Windows machines. In addition, everyone can access everyone else's shared files. You can see how samba can be very useful if you have a network of both Windows as well as Linux machines.

Samba configurations are slightly different depending on the distribution you're using. Therefore, this tutorial explains how it's done on a RedHat Linux machine, as this is my distro of choice, and the only one I've ever installed samba on. The following method has been used by me on RedHat 7.2, 7.3, and 8.

Installing Samba

The first step to configuring samba is, obviously, to make sure that it's installed. In most cases, this will already be the case. It is often a good idea to install the samba daemon package with the RedHat installation.

You can test to see if samba is installed by typing rpm -q samba in a terminal. This performs a query on the samba package. If installed, it will indicate the version. If not, it will indicate "package not installed".

If samba is not currently installed, there are a multitude of places to get it. The RPM package is available on the RedHat CDs, on the RedHat network, or straight from www.samba.org or one of the samba mirror sites. In addition, you might wish to find it at www.rpmfind.net, a nice resource for RPM packages.

Once you have the samba RPM package downloaded somewhere on your harddrive, it's time to install it. Browse to where the file is located and perform one of the following two operations:
if samba is not currently installed,
rpm -i samba.rpm
(replace samba.rpm with the full version name of the file)

if you wish to upgrade your samba version,
rpm -U samba.rpm

Now that samba is installed, we can work on configuring this program.

smb.conf file

All of samba is configured in one single file, the smb.conf file. This file, located at /etc/samba/smb.conf, allows you to specify which resources on the linux machine you wish to share and who they can be accessed by.

A fresh installation of samba will include a sample smb.conf file. This file is completely commented, pointing out all of your available options, and how you can change them. However, samba is an extremely powerful tool, and most casual users have no need for 3/4 of the contents of this sample file. Therefore, I'm providing my own smb.conf file below. If you wish to just share a few folders across a small home LAN, you might be better off basing your own smb.conf file off of mine, as opposed to the long-winded sample file.
[global]
workgroup = PUTIEVILLE
server string = My Lil Linux Box
hosts allow = 192.168. 127.
log file = /var/log/samba/%m.log
security = user
encrypt passwords = yes
smb passwd file = /etc/samba/smbpasswd
socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192

[Downloads]
comment = Downloads
path = /home/windisk/Downloads
browseable = yes
writable = yes
public = yes
read only = no

[homes]
comment = My Home Directory
browseable = yes
writable = yes
public = yes
read only = no

[printers]
path = /var/spool/samba
public = yes
guest ok = yes
printable = yes
browseable = yes
writable = yes
read only = no


Samba Users

Since we're using user level security (the best option when connecting to a WinNT based machine, such as Windows 2000 or Windows XP), we need to set up samba users.

First, lets create the smbpasswd file that we defined in the smb.conf file. The best way to go about this is to create it based on your existing /etc/passwd file. In other words, samba users are created based on existing linux users:
cat /etc/passwd | mksmbpasswd.sh > /etc/samba/smbpasswd

Chmod 600 this file (/etc/samba/smbpasswd) so that only root has read and write permissions.

However, this file only copies over Linux users to samba users. It doesn't copy over their passwords, as well. Therefore, use the following command to set each samba user's password:
smbpasswd username

Obviously, replace username with each of your user's usernames. You will then be prompted to enter a password for this user account. I like to set my samba user's passwords the same as their linux user counterparts. However, this isn't necessary.

Samba Service

Now that everything has been configured, the final step is to start the samba service. Samba runs in the background as a linux daemon. Therefore, it can be controlled by typing:
service smb start
service smb stop
service smb restart

Note that once the computer is restarted or shutdown, the samba service won't start up again the next time. I use the GUI (xwindows) program serviceconf to set up all my services to execute automatically.

Connecting To A Samba Resource

Now that everything should be working, let's test it out. We use the samba client to connect to a samba resource. For testing purposes, we can connect to localhost.
smbclient //localhost/Downloads

You must specify the name of the computer as well as the resource you wish to connect to. In this case, I can connect to the Downloads resource because I specified this resource in my smb.conf file (note it points to /home/windisk/Downloads).

Since you are using the samba client while already logged in as a linux user, you will only be prompted for a password. The username will be assumed to be the samba counterpart of the linux username you're currently logged in as.

If you wish, you can go to a Windows machine such as Windows XP. If you open My Network Places, and browse to your workgroup, your linux machine should be listed. When trying to access it, you should be prompted with a username and password. This can be any of the samba users you previously created. Once logged in, you should see a listing of all available resources available.

Congratulations! Samba should now successfully be set up and working on your network!
Last edited by cscgal; May 25th, 2008 at 5:11 pm. Reason: Formatting
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/DaniWeb
And if you're interested in Internet marketing there is twitter.com/DaniWebAds
Reply With Quote Quick reply to this message  
Join Date: Dec 2003
Posts: 6,439
Reputation: DMR will become famous soon enough DMR will become famous soon enough 
Solved Threads: 363
Team Colleague
DMR's Avatar
DMR DMR is offline Offline
Wombat At Large

Re: How to Configure Samba on RedHat Linux

 
0
  #2
Dec 4th, 2003
Two further Samba references, although parts of them might be out of date:

O'Reilly's Using Samba

Samba/SWAT configuration help. Swat (Samba Web Administration Tool) is a popular GUI front-end for Samba configuration. Webmin, although not limited to Samba configuration, is another popular GUI config tool.
*Note: When reading documentation concerning Samba/SWAT, watch out for references to inetd. In most cases, that material applies only to older distros, as inetd is deprecated, and has been replaced by xinetd (which has an entirely different config structure).

Also, for a Linux equivalent to Windows' "Network Neighborhood/ My Network Places" network browsers, check out LinNeighborhood.
Last edited by DMR; Dec 4th, 2003 at 11:48 pm.
Reply With Quote Quick reply to this message  
Join Date: Oct 2003
Posts: 588
Reputation: bluedos82 is an unknown quantity at this point 
Solved Threads: 0
bluedos82's Avatar
bluedos82 bluedos82 is offline Offline
Posting Pro

Re: How to Configure Samba on RedHat Linux

 
0
  #3
Dec 8th, 2003
Man, where was this about 3 months ago when I needed it! UGH! Oh well. You guys do a good job.
Reply With Quote Quick reply to this message  
Join Date: Jan 2004
Posts: 195
Reputation: gortonsfi is an unknown quantity at this point 
Solved Threads: 3
gortonsfi's Avatar
gortonsfi gortonsfi is offline Offline
Junior Poster

Re: How to Configure Samba on RedHat Linux

 
0
  #4
Jan 19th, 2004
Heya, I used your guide as a reference after encountering problems. Now I'm connecting just fine from my apple even copying files to and from, but it won't let me make or manipulate subfolders inside my share. Any ideas as to what is going wrong?
Reply With Quote Quick reply to this message  
Join Date: Aug 2003
Posts: 372
Reputation: TheOgre is a jewel in the rough TheOgre is a jewel in the rough TheOgre is a jewel in the rough 
Solved Threads: 6
TheOgre's Avatar
TheOgre TheOgre is offline Offline
Posting Whiz

Re: How to Configure Samba on RedHat Linux

 
0
  #5
Jan 29th, 2004
chmod 777 /path/to/samba/share
provided you want everyone to have read+write access

man chmod for more info about assigning attributes to a directory/file
If you spend more on coffee than on IT security, you will be hacked.
What's more, you deserve to be hacked.
-- former White House cybersecurity czar Richard Clarke
Reply With Quote Quick reply to this message  
Join Date: Feb 2004
Posts: 1
Reputation: rollinsdr is an unknown quantity at this point 
Solved Threads: 0
rollinsdr rollinsdr is offline Offline
Newbie Poster

Re: How to Configure Samba on RedHat Linux

 
0
  #6
Feb 26th, 2004
I used your config file but I had to change one thing to make things work on my network.

I had to add:

[global]
netbios name = yourServerName

Before that, the Server was showing up as localHost and said that I had a duplicate name on the network and I couldn't access the share.

Thanks for all the help otherwise!!!
Reply With Quote Quick reply to this message  
Join Date: Mar 2004
Posts: 1,620
Reputation: kc0arf is a jewel in the rough kc0arf is a jewel in the rough kc0arf is a jewel in the rough 
Solved Threads: 51
Team Colleague
kc0arf kc0arf is offline Offline
Posting Virtuoso

Re: How to Configure Samba on RedHat Linux

 
0
  #7
Jun 21st, 2004
Hello,

IF this computer that you have SAMBA installed on is going to be part of the internet, and if this computer is the firewall, then I would strongly suggest that you firewall out the Microsoft ports, before someone tries to attach to your machine via the internet. I would also firewall out any OUTBOUND messages that SAMBA will try to make so that your computer doesn't show up on someone's Network Neighborhood.

Inside IPTABLES:

## Explicit drops of Samba ports
$IPTABLES -A tcp_packets -p TCP -s 0/0 --dport 139 -j DROP
$IPTABLES -A tcp_packets -p TCP -s 0/0 --dport 445 -j DROP
$IPTABLES -A udpin_packets -p UDP -s 0/0 --dport 139 -j DROP
$IPTABLES -A udpin_packets -p UDP -s 0/0 --dport 445 -j DROP

(I have a rule called tcp_packets and udpin_packets. You will have to modify that to fit your IPTABLES firewall. If you are using something else to firewall, take the port numbers and work with it)

# Rule Test to drop Microsoft packets outbound from server.
# Want to stop Samba Advertising
$IPTABLES -A OUTPUT -p TCP -o $INET_IFACE --dport 139 -j DROP
$IPTABLES -A OUTPUT -p TCP -o $INET_IFACE --dport 445 -j DROP
$IPTABLES -A OUTPUT -p TCP -o $INET_IFACE --dport 32875 -j DROP
$IPTABLES -A OUTPUT -p UDP -o $INET_IFACE --source-port 32875 -j DROP
$IPTABLES -A OUTPUT -p UDP -o $INET_IFACE --dport 137 -j DROP

If anyone needs more help with this, come find me.

Christian
Reply With Quote Quick reply to this message  
Join Date: Dec 2003
Posts: 6,439
Reputation: DMR will become famous soon enough DMR will become famous soon enough 
Solved Threads: 363
Team Colleague
DMR's Avatar
DMR DMR is offline Offline
Wombat At Large

Re: How to Configure Samba on RedHat Linux

 
0
  #8
Jul 9th, 2004
HoWS,

We ask that members who have a question start their own thread and post their question in that thread. In that light, I've split your post here into its own thread in the main Linux forum; you can find it here:

http://www.daniweb.com/techtalkforum...ead.php?t=7934
"May the Wombat of Happiness snuffle through your underbrush."
- Ancient Aborigine blessing


Please do not contact me by email or PM for help. We're all volunteers here, and only have so much free time to dedicate to our efforts.

However, if I've been working on a thread with you already, and seem to have "forgotten" your thread, please do send me a message. I try not to let things slip through the cracks, but it does happen sometimes.
Reply With Quote Quick reply to this message  
Join Date: Dec 2003
Posts: 6,439
Reputation: DMR will become famous soon enough DMR will become famous soon enough 
Solved Threads: 363
Team Colleague
DMR's Avatar
DMR DMR is offline Offline
Wombat At Large

Re: How to Configure Samba on RedHat Linux

 
0
  #9
Aug 19th, 2004
Cr4nberry,

For the reason given in my previous post above, I've split your post into its own thread in the main Linux forum. You can find it here:

http://www.daniweb.com/techtalkforums/thread9598.html
"May the Wombat of Happiness snuffle through your underbrush."
- Ancient Aborigine blessing


Please do not contact me by email or PM for help. We're all volunteers here, and only have so much free time to dedicate to our efforts.

However, if I've been working on a thread with you already, and seem to have "forgotten" your thread, please do send me a message. I try not to let things slip through the cracks, but it does happen sometimes.
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 1
Reputation: quicksilver is an unknown quantity at this point 
Solved Threads: 0
quicksilver's Avatar
quicksilver quicksilver is offline Offline
Newbie Poster

Re: How to Configure Samba on RedHat Linux

 
0
  #10
Apr 8th, 2005
pls help me i have a problem in my pc.it uses red hat linux 9 and i can see it in windows pc but not in linux based pc?what can i do to solved that problem....


thanks!!!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the *nix Hardware Configuration Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC