Setting up a Samba share on Fedora 26

This post goes through the process of setting up a Windows Samba share on Fedora 26. This will let me access folders on the Fedora machine using windows explorer.

Installing the necessary programs

To set up samba on Fedora we need to install some programs first. These are samba and samba-client. For good measure once these have been installed we will reboot the machine. This can be done as follows.

sudo dnf install samba samba-client
sudo reboot

Once the machine has rebooted we are ready to configure samba

Configuring Samba to share folders

The configuration file for Samba is located at /etc/samba/smb.conf. One of the changes I am going to make is to change the workgroup. Here I am going to change it to the workgroup used at home, “BUNKER”.

I am going to add one new share with the below template.

[WD1TB]
comment = Public folder
path = /home/public
valid users = @samba
force group = samba
create mask = 0660
directory mask = 0771
read only = no

Here I name the folder “Public folder” and add the path to the folder /home/public/

I set the users that are allowed to access the share to @samba. This means that all users who have the samba group are allowed to access this share. By forcing the group to samba all users accessing the folders will be doing so as the samba user. This can resolve a number of permission issues.

The create mask and directory mask are set up so that any files or directories are created with the given mask.

Finally setting read only can allow you to make read only shares. For this case I want to be able to write to the folder.

Now samba has been configured I need to ensure it always runs when the machine turns on. I can do this with the following two commands.

sudo systemctl enable smb nmb
sudo systemctl start smb nmb

The first enables samba so that it will start on every system boot. The second starts it for this session.

In addition to starting samba we need to add a service rule to allow samba through the default Fedora firewall. The following two commands add samba as a permitted service and reloads the rules to allow it through.

firewall-cmd --add-service=samba --permanent
firewall-cmd --reload

Now samba is configured I need to give my user access to it.

Setting up samba to access the folders

Now that I have configured samba I need to set it up for my user. Since I have configured it to work for those users with the samba group I need to create this group and assign it to my user.

sudo groupadd samba
sudo usermod -aG samba chewett

Once the group has been added I need to set my samba password. This can be done for any user by running the following command.

smbpasswd -a chewett

Once this is done my user chewett will be able to access samba.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.