Quick News Bit

How to install and configure Samba on RHEL-based Linux distributions

0
Two programmers collaborate on code, one is typing and one is pointing at a line of code.
Image: joyfotoliakid/Adobe Stock

Samba is a key component of using Linux in a business environment. With this subsystem, users can share directories across the network so others can view and even edit the contents within.

SEE: 40+ open source and Linux terms you need to know (TechRepublic Premium)

With some Linux distributions, such as Ubuntu Desktop, many of the pieces are in place by default. Other distributions, such as those based on Red Hat Enterprise Linux, might not include everything required to get Samba working out of the box. That’s what I’m here for: I want to walk you through the process of getting Samba up and running on RHEL-based Linux distributions.

What you’ll need to get Samba running on RHEL-based distributions

The only things you’ll need to get Samba installed are a RHEL-based Linux distribution and a user with sudo privileges. I’ll demonstrate with EuroLinux, but this process should work with just about any RHEL-based distribution.

How to install Samba

The first thing we must do is install Samba. For this, log in to your Linux distribution and open a terminal. From the terminal window, issue the command:

sudo dnf install samba samba-common samba-client -y

Make sure the service is started and enabled with:

sudo systemctl enable --now smb

That’s it for the installation. Let’s create a share.

How to create a samba share

Let’s create a share within /srv. For that, create a new folder with the command:

sudo mkdir -p /srv/samba/euroshare

You can name the share within the samba directory whatever you like.

Give the new share the correct permissions with the following commands:

sudo chmod -R 755 /srv/samba/euroshare
sudo chown -R nobody:nobody /srv/samba/euroshare
sudo chcon -t samba_share_t /srv/samba/euroshare

Next, we’ll create a share from within the smb.conf file. Open the file for editing with:

sudo nano /etc/samba/smb.conf

At the bottom of that file, add the following:

[Public]
path = /srv/samba/euroshare
public = yes
guest only = yes
writable = yes
force create mode = 0666
force directory mode = 0777
browseable = yes

Save and close the file. Restart Samba with:

sudo systemctl restart smb

How to adjust the firewall

We now must open the firewall such that Samba can be accessed. First, create the new firewall rule with:

sudo firewall-cmd --add-service=samba --zone=public --permanent

Reload the firewall with:

sudo firewall-cmd --reload

At this point, the Samba share should be accessible from other machines on your network. And with the smb.conf Public configuration, even anonymous users have both read and write access to the share.

How to limit access to registered users

If you don’t want such wide access granted to the share, you can set it up such that only legitimate users can access the share. The one caveat to this is that the user will have to have an account on your machine. Of course, you could always create a sambashare user, so you only need to give out the credentials for that user. To create the sambashare user, issue the command:

sudo adduser sambashare

Make sure to give the user a strong/unique password.

Next, give the new user a samba password with:

sudo smbpasswd -a sambashare

Next, enable the user with:

sudo smbpasswd -e sambashare

Next, the smb.conf Public entry should look like this:

[Public]
path = /srv/samba/euroshare
browsable = yes
writable = yes
guest ok = yes
read only = no
create mask = 0644
directory mask = 2777

Next, we’ll need to give the sambashare user access to the folder with:

sudo chown -R sambashare /srv/samba/euroshare

Restart Samba with:

sudo systemctl restart smb

Now, the sambashare user should have full access to the share.

And that’s how we do the Samba with RHEL-based Linux distribution. You can now dance it out, knowing you’ve made it possible for users on your network to access the files and folders within.

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.

For all the latest Technology News Click Here 

 For the latest news and updates, follow us on Google News

Read original article here

Denial of responsibility! NewsBit.us is an automatic aggregator around the global media. All the content are available free on Internet. We have just arranged it in one platform for educational purpose only. In each content, the hyperlink to the primary source is specified. All trademarks belong to their rightful owners, all materials to their authors. If you are the owner of the content and do not want us to publish your materials on our website, please contact us by email – [email protected]. The content will be deleted within 24 hours.

Leave a comment