DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   *nix Hardware Configuration (http://www.daniweb.com/forums/forum119.html)
-   -   How to Configure Samba on RedHat Linux (http://www.daniweb.com/forums/thread1741.html)

cscgal Nov 16th, 2003 11:21 am
How to Configure Samba on RedHat Linux
 
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!

DMR Dec 4th, 2003 10:31 pm
Re: How to Configure Samba on RedHat Linux
 
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.

bluedos82 Dec 8th, 2003 11:41 am
Re: How to Configure Samba on RedHat Linux
 
Man, where was this about 3 months ago when I needed it! UGH! Oh well. You guys do a good job.

gortonsfi Jan 19th, 2004 3:44 pm
Re: How to Configure Samba on RedHat Linux
 
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?

TheOgre Jan 29th, 2004 11:11 am
Re: How to Configure Samba on RedHat Linux
 
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

rollinsdr Feb 26th, 2004 1:56 pm
Re: How to Configure Samba on RedHat Linux
 
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!!!

kc0arf Jun 21st, 2004 12:28 am
Re: How to Configure Samba on RedHat Linux
 
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

DMR Jul 9th, 2004 4:08 pm
Re: How to Configure Samba on RedHat Linux
 
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

DMR Aug 19th, 2004 1:39 pm
Re: How to Configure Samba on RedHat Linux
 
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

quicksilver Apr 8th, 2005 3:30 am
Re: How to Configure Samba on RedHat Linux
 
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!!!


All times are GMT -4. The time now is 11:38 pm.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC