Wednesday, November 10, 2010

Configuring SAMBA on RHEL/FEDORA

Hi Guys,

Today, i am going to tell you that how to configure SAMBA on RHEL/FEDORA platform for sharing files.

Prerequisites:-

* a machine with RHEL/FEDORA installation
* YUM Server configured

Steps to go:-

1) Install the samba package from YUM utility.
# yum install samba

2) Make a directory that is to be shared on SAMBA (in my case i am making /linux):
# mkdir /linux

3) Now, open the samba configuration file i.e. smb.conf in vi editor or any editor you like and search "hosts" in there and edit the lines as:

# vim /etc/smb/smb.conf
hosts allow = 127. 192.168.1.

[Shared]
comment=Linux Samba Shares
path=/linux
public=yes
browseable=yes
valid users = aman
:wq
save and exit

Here, we are specifying the network on which SAMBA shares is available. I am sharing the SAMBA with the machines on the network 192.168.1.0. So, put your network here(on which you want to share files) in front of the "hosts allow = ".

Then, we are specifying the name of the share as "Shared" or you can change it for your own. Then, specifying the comment for the share, its path means the path to the shared folder. Defining it public so that people can share it on the network. Making it browseable and restricting with the user "aman". Means only user "aman" can access its shares.

4) Adding a user to the network(in my case user is "aman"):
For this step a user should be on your machine, means on the same machine from which you are sharing /linux.

# useradd aman
# smbpasswd -a aman
password:
confirm:


5) Now, changing context label of the sharing folder i.e. /linux:

You can check context label of the folder using the command :
# ls -dZ /linux

Change the context label as:
# chcon -t samba_share_t /linux

Context label is a very important part. If we don't set context label then SELINUX won't be aware of the samba shares.

6) Now, setting selinux boolean values:

# setsebool -P samba_enable_home_dirs on
# setsebool -P use_samba_home_dirs on

Option "-P" is for making it permanent and saving it for across reboots.

7) Now, restart SAMBA service:

# service smb restart; chkconfig smb on

8) Now, goto another machine on the network and check for the samba shares with the following commands:
# smbclient //192.168.1.58/shared -U aman
password:
smb>

use the password you just setted up using the "smbpasswd" above to login.

or

# smbclient -L //192.168.1.58

NOTE:- The IP address 192.168.1.58 is of the machine on which we have configured SAMBA.

Enjoy Sharing....:)

No comments:

Post a Comment