Configure Samba Share in Red Hat Enterprise Linux 7 (RHEL7)
RHEL 7, by programr101.
This article describes how to configure a basic Samba share in Red
Hat Enterprise Linux 7 (RHEL7). This procedure will describe how to
configure a share to work with SELinux and the firewall. For those
unfamiliar with samba it is software that allows windows clients to
connect to Linux based servers and share files and printing.
Note: the commands in this guide need to be run as the root user.
1) The first step in the process is to install the samba software on your machine. Use the command below to install all of the Samba packages.
2) Create the directory containing the contents you would like to share. In this example the directory will be “/samba_share”
3) Change the permission level on the directory to “777”
This allows all users to read, write, and execute files from this directory.
4) Change the SELinux file context so that it can be shared
This command changes the SELinux security context on the directory to “samba_share_t” which will allow the contents of the directory to be shared via samba. Users wont be able to access the share if the SELinux context is not changed.
5) Now we need to create a samba user that will be able to access the shared directory. We will use the user “johndoe” to accomplish this.
if the user “johndoe” has not been added to the system create the account with the following commands.
Once the user has been added you can create the user’s samba account with the following commands.
(create the password)
5) Configure the “/etc/samba/smb.conf” file with the directory share information. Its a good idea to create a backup of this file before making any edits.
Navigate toward the bottom of the “/etc/samba/smb.conf” file and look for the “Share Definitions” and add the following lines to define the share:
6) Enable and start the samba service
7) Create a firewall rule to allow connections to the samba share
8) I would also recommend rebooting the system
9) You should now be able to connect to your samba share using a windows computer along with the credentials for the user “johndoe”
There are other ways of accomplishing this task so please leave any recommendations you have.
Note: the commands in this guide need to be run as the root user.
1) The first step in the process is to install the samba software on your machine. Use the command below to install all of the Samba packages.
yum -y install samba*
2) Create the directory containing the contents you would like to share. In this example the directory will be “/samba_share”
mkdir /samba_share
3) Change the permission level on the directory to “777”
chmod 777 /samba_share
This allows all users to read, write, and execute files from this directory.
4) Change the SELinux file context so that it can be shared
chcon -t samba_share_t /samba_share/
This command changes the SELinux security context on the directory to “samba_share_t” which will allow the contents of the directory to be shared via samba. Users wont be able to access the share if the SELinux context is not changed.
5) Now we need to create a samba user that will be able to access the shared directory. We will use the user “johndoe” to accomplish this.
if the user “johndoe” has not been added to the system create the account with the following commands.
useradd johndoe
passwd johndoe
Once the user has been added you can create the user’s samba account with the following commands.
smbpasswd -a johndoe
(create the password)
5) Configure the “/etc/samba/smb.conf” file with the directory share information. Its a good idea to create a backup of this file before making any edits.
Navigate toward the bottom of the “/etc/samba/smb.conf” file and look for the “Share Definitions” and add the following lines to define the share:
[samba_share]
comment = Samba share
path = /samba_share
browseable = yes
valid users = johndoe
writable = yes
6) Enable and start the samba service
systemctl enable smb.service
systemctl start smb.service
7) Create a firewall rule to allow connections to the samba share
firewall-cmd –-permanent –-add-service=samba
systemctl restart firewalld
8) I would also recommend rebooting the system
9) You should now be able to connect to your samba share using a windows computer along with the credentials for the user “johndoe”
There are other ways of accomplishing this task so please leave any recommendations you have.
Comments
Post a Comment