Difference between revisions of "Sharing Files between RHEL 6 and Windows Systems with Samba"
(→Accessing Windows Shares from RHEL 6) |
|||
Line 203: | Line 203: | ||
To obtain a list of Windows workgroups on the network, double click on the Windows Network icon. From within the list of workgroups double click on the desired group to obtain a listing of servers available for access: | To obtain a list of Windows workgroups on the network, double click on the Windows Network icon. From within the list of workgroups double click on the desired group to obtain a listing of servers available for access: | ||
− | + | <google>RHEL6BOX</google> | |
[[Image:rhel6_samba_windows_resources.jpg]] | [[Image:rhel6_samba_windows_resources.jpg]] |
Revision as of 20:25, 1 April 2011
Previous | Table of Contents | Next |
Using NFS to Share RHEL 6 Folders with Remote Linux and UNIX Systems | Configuring an RHEL 6 Based Web Server |
<google>BUY_RHEL6</google>
Although Linux is increasingly making inroads into the desktop market, its origins are very much server based. It is not surprising therefore that Red Hat Enterprise Linux 6 has the ability to act as a file server. It is also extremely common for RHEL and Windows systems to be used side by side in networked environments. It is a common requirement therefore that files on an RHEL 6 system be accessible to Linux, UNIX and Windows based systems over network connections. Similarly, shared folders and printers residing on Windows systems must also be accessible from RHEL based systems.
Windows systems share resources such as file systems and printers using a protocol called Server Message Block (SMB). In order for a RHEL system to serve such resources over a network to a Windows system and vice versa it must, therefore, support SMB. This is achieved using technology called Samba. In addition to providing integration between Linux and Windows systems, Samba may also be used to provide folder sharing between Linux systems (as an alternative to NFS which was covered in the previous chapter). In this chapter we will look at the steps necessary to share file system resources and printers on an RHEL system with remote Windows and Linux systems.
Samba and Samba Client
Samba allows both RHEL resources to be shared with Windows systems and Windows resources to be shared with RHEL systems. RHEL accesses Windows resources using a package named samba-client. RHEL resources, on the other hand, are shared with Windows systems using a package named samba. Typically, the samba-client is installed and configured by default allowing you to browse available Windows resources without any additional work (this is covered later in the chapter). In order to allow an RHEL 6 system to share resources with Windows systems, however, some more work is required.
Installing Samba on an RHEL 6 System
The default settings used during the RHEL 6 installation process do not install the samba package. Unless you specifically requested that Samba be installed it is unlikely that you have Samba installed on your system. To check whether Samba is installed, open a terminal window (Applications -> System Tools -> Terminal) and run the following rpm command:
rpm -q samba
If Samba is installed, the rpm command will generate output similar to the following:
samba-3.5.4-68.el6_0.1.x86_64
If Samba is not installed, rpm will return with "package samba is not installed". That being the case, it can be installed using the yum command-line tool:
su - yum install samba
The above command will install both the samba package and the samba-common dependency package.
If you prefer to use the graphical tool to perform the Samba installation, select Applications -> Add/Remove Software, enter the root password if prompted to do so and then perform a search for Samba. When the list of matching packages appears, set the checkbox next to the samba and samba-common packages and click on Apply to initiate the installation.
Configuring the RHEL Firewall to Enable Samba
Next, the firewall currently protecting the RHEL system needs to be configured to allow Samba traffic. To achieve this, run the Firewall Configuration tool by selecting the System -> Administration -> Firewall menu option and select the check box next to Samba in the Trusted Services section of the tool. Click Apply and OK to commit the change.
Before any resources on the RHEL system can be accessed from the Windows systems, however, some additional configuration steps are necessary.
Configuring the smb.conf File
In releases of Red Hat Enterprise Linux prior to release 6, a user friendly graphical tool named system-config-samba was provided to assist in the configuration of Samba. In RHEL 6, however, this tool has been removed. This means that the Samba environment must be configured manually within the /etc/samba/smb.conf file and using the smbpasswd command line tool. Whilst the loss of system-config-samba may be mourned by those who relied on it, the tool’s simplicity actually masked many of the more advanced features of Samba. In practice, much more can be achieved by tasking the time to understand the intricacies of the smb.conf file.
Samba is a highly flexible and configurable system that provides many different options for controlling how resources are shared on Windows networks. This flexibility can lead to the sense that Samba is overly complex to work with. In reality, however, many of the configuration options are not needed by the typical installation, and the learning curve to set up a basic configuration is actually quite short.
For the purposes of this chapter we will look at joining an RHEL 6 system to a Windows workgroup and setting up a directory as a shared resource that can be accessed by a specific user.
The first step, therefore, is to gain root privileges and to load the /etc/samba/smb.conf file into a suitable editor, for example:
su – gedit /etc/samba/smb.conf
Configuring the [global] Section
The smb.conf file is divided into sections. The first section is the [global] section where settings can be specified that apply to the entire Samba configuration. Whilst these settings are global, each option may be overridden within other sections of the configuration file.
The first task is to define the name of the Windows workgroup on which the RHEL 6 resources are to be shared. This is controlled via the workgroup = directive of the [global] section which by default is configured as follows:
workgroup = MYGROUP
Begin by changing this to the actual name of the workgroup. For example, if the workgroup is named WORKGROUP (the default for most Windows networks):
workgroup = workgroup
The next step is to configure a shared resource (in other words a resource that will be accessible from other systems on the Windows network). In order to achieve this, the section is given a name by which it will be referred to when shared. For example, if we plan to share the /tmp directory of our RHEL 6 system, we might entitle the section [tmp]. In this section a variety of configuration options are possible. For the purposes of this example, however, we will simply define the directory that is to be shared, indicate that the directory is browsable and writable and declare the users that are allowed to access the shared resource (in this case a user named demo):
[tmp] path = /tmp writeable = yes browseable = yes valid users = demo
Creating a Samba User
Any user that requires access to a Samba shared resource must be configured as a Samba User and assigned a password. This task is achieved using the smbpasswd command line tool. In our example smb.conf file we stated the user demo is entitled to access the /tmp directory of our RHEL 6 system. In order to fulfill this requirement, therefore, we must add demo as a samba user as follows:
# su - # smbpasswd -a demo New SMB password: Retype new SMB password: Added user demo.
Now that we have completed the configuration of a very basic Samba server, it is time to test our configuration file and then start the Samba services.
Testing the smb.conf File
The settings in the smb.conf file may be tested using the testparm command line tool as follows:
# testparm Load smb config files from /etc/samba/smb.conf rlimit_max: rlimit_max (1024) below minimum Windows limit (16384) Processing section "[homes]" Processing section "[printers]" Processing section "[tmp]" Loaded services file OK. Server role: ROLE_STANDALONE Press enter to see a dump of your service definitions [global] server string = Samba Server Version %v log file = /var/log/samba/log.%m max log size = 50 cups options = raw [homes] comment = Home Directories read only = No browseable = No [printers] comment = All Printers path = /var/spool/samba printable = Yes browseable = No [tmp] path = /tmp valid users = demo read only = No
Starting the Samba and NetBIOS Name Services on RHEL 6
In order for an RHEL 6 server to operate within a Windows network both the Samba (SMB) and NetBOIS nameservice (NMB) services must be started. To identify if the services are already running, the following command may be executed with root privileges in a terminal window:
su – /sbin/service smb status smbd is stopped # /sbin/service nmb status nmbd is stopped
If the services are reported as currently running and you have made changes to the smb.conf file it will be necessary to restart the services in order to pick up the changes:
/sbin/service smb restart /sbin/service nmb restart
If, on the other hand, the services are currently stopped, start them as follows:
/sbin/service smb start /sbin/service nmb start
Now that the Samba resources are configured and the services are running, it is time to access the shared resource from a Windows system. On a suitable Windows system on the same workgroup as the RHEL 6 system, open Windows Explorer and navigate to the Network page. At this point, explorer should search the network and list any systems using the SMB protocol that it finds. The following figure illustrates an RHEL 6 system named rhel6 located using Windows Explorer on a Windows 7 system:
Double clicking on the RHEL 6 host will prompt for the name and password of a user with access privileges. In this case it is the demo account that we configured using the smbpasswd tool. Entering the username and password will result in the shared resources configured for that user appearing the explorer window, including the tmp resource previously configured:
Double clicking on the tmp shred resource will display a listing of the files and directories contained therein.
As previously mentioned, Samba is a two way street, allowing not only Windows systems to access files and printers hosted on an RHEL 6 system, but also allowing the RHEL system to access shared resources on Windows systems. This is achieved using the samba-client package which is installed by default under most RHEL 6 configurations. If it is not currently installed, install it from a Terminal window as follows:
su – yum install samba-client
To access any shared resources on a Windows system, begin by selecting the Places -> Network desktop menu option. This will display the Network browser dialog including an icon for the Windows Network (if one is detected) as illustrated in the following figure:
To obtain a list of Windows workgroups on the network, double click on the Windows Network icon. From within the list of workgroups double click on the desired group to obtain a listing of servers available for access:
<google>RHEL6BOX</google>
Finally, double clicking on a computer will list the shared resources available for access from the RHEL client.
Summary
In this chapter we have looked at the steps necessary to configure an RHEL 6 system to act as both a Samba client and server allowing the sharing of resources with other systems on a Windows based network. In the case of Samba server configuration in particular we have only scratched the surface of the configuration options available. A full over of Samba would require an entire book. Many such publications and online resources are available if you would like to learn more. Another good place to start is to type man samba in a terminal window.
<google>BUY_RHEL6_BOTTOM</google>
Previous | Table of Contents | Next |
Using NFS to Share RHEL 6 Folders with Remote Linux and UNIX Systems | Configuring an RHEL 6 Based Web Server |