You are on page 1of 3

RHEL 6 for the Clueless: Samba Server (Updated)

If you intend using your RHEL machine as a server among Windows machines, one of the first things you should consider is using Samba. This is the Open Source implementation of Windows SMB. Samba allows your RHEL box to provide a compatibility layer so a Windows computer on the same network, such as your home LAN, can read portions of the Linux file system natively. It is also the only way I know you can have Linux operate as a print server for Windows sharing. That is, if you have a printer connected to your RHEL box and working, Samba allows you to provide a Windows computer access, provided that Windows box has its own driver for it. There seems to be no documentation from Red Hat, and Samba itself offers a huge documentation library because there are too many options for any sane person to examine. There are some items youll need to prepare before starting: username (so the Windows user can login from their machine), password, and the network IP address on your LAN for the other computer(s), and a shared directory with world write permissions. If a printer is involved, make sure its setup to share. RHEL provides a GUI tool for printer setup. If your printer is connected via USB, it should be recognized immediately if RHEL knows what it is. This is the place to check. There isnt space here to chase down all the various problems you might encounter, so if it doesnt pretty much work, and you cant get it recognized and configured through the Administration menu, youll need to engage your favorite search engine using your printer model with the keyword linux, or terms RHEL and Fedora and make the most of it. In the menu system for the printer configuration tool is a place to checkmark some boxes to share the printer. Ive found a couple of tutorials on Samba, but neither one had all the right information. After fighting with it a bit, this is what I did to get it working. Install Samba by logging into a Terminal as root:
yum install samba

Create shared directory; I used /home/shared:


mkdir /home/shared chmod a+w /home/shared chcon -t samba_share_t /home/shared

That last line insures the SELinux security system knows to allow outside systems to poke around in that folder. Now anyone using this computer can move files in and out of the folder, as well as the Samba users. Add a Samba user. This is a different task than simply adding a user account. There is a GUI tool for adding Linux user accounts to the machine for them to use the computer itself. However, Samba users must be handled differently, so that the system forces them to use the Samba server.

useradd -c "Real Name" -d /home/samba-username -s /sbin/nologin sambausername

Thats all one line. As usual, substitute the actual Real Name and samba-username in the command above. Then create the Samba password. Remember what we said about coming up with good passwords:
smbpasswd -a samba-username

It will prompt for the password, which you type in blindly:


New SMB password: Retype new SMB password: Added user username.

Edit smbusers:
gedit /etc/samba/smbusers

This will open the default text editor. Scan down the file until you see something like this:
root = administrator admin nobody = guest pcguest smbguest

Immediately below this, add a line with this format:


username = samba-username

so RHEL recognizes the person logging in from the Winbox by their samba-username. Close this file by saving it, then open a file in the same place: /etc/samba/lmhosts. The first line should show: 127.0.0.1 localhost. Add another line below that: 192.168.1.102 hostname. That is, the IP address on your network of the Windows box, and its hostname in lower case. If you dont know how to find the IP address on Windows, use these instructions. To get the hostname, try this page from the same site. Save that file. Then open: /etc/samba/smb.conf. Find the section headed [global]. Change the workgroup name to whatever your Windows computer will be seeking. Default is workgroup in lower case letters. Youll need to remove the semicolon in front of the next line and provide a proper hostname for the netbios name, which would be the name you gave your RHEL computer during installation, again in lower case. Remove the semicolon from the next line and the IP address numbers from the sample; all we need are the two interfaces lo eth0. Below that is a line with hostsallow as a model. Below that, start a new line with the same indentation:
hosts allow = 127. 192.168.1.

The 127. is the IP address for everything on your own machine. The other (192.168.1.) is the private LAN network I use for my home router; by leaving off the last section after the dot, it automatically includes every computer with that prefix, which is reserved for LANs. Go all the way to the bottom of the file and add some lines. I named my shared directory shared. Thus, the section heading should be named the same:
[shared] path = /home/shared writeable = yes browseable = yes read only = No guest ok = Yes public = Yes valid users = username1 username2 create mask = 0666 directory mask = 0777

Now change the firewall to allow Samba to get through. You can use the tool in System > Administration > Firewall. Simply scan down the list to Samba and checkmark the box. Optionally checkmark IPP printer sharing. Then hit Apply. Now we start the service manually; its actually two services:
/sbin/service smb start /sbin/service nmb start

Test whether your Windows box can find the server. In Win7 and Vista, thats via your file manager window. On the left hand side look for the Network icon. Double click to open and the computer should search for other machines. Your RHEL box should eventually show up by its hostname. Double click and see if you can login from there. If successful, your shared folder and any printer youve permitted will also show. For XP and Win2K, its a similar idea using the file manager. The simplest way is to right-click on My Computer and select Explore so that the left pane shows the various drives, and should display a network connection to the RHEL server. If it works and you dont have to cry for help, youll want to make it a normal service always running. System > Administration > Services find nmb and smb and click the Enable button. From now on, upon boot the system will start the two services automatically.

You might also like