Skip to content

CentOS Samba Shares

Today I wanted to share some files between 2 of my Digital Ocean droplets and I thought it would be a fantastic time to look at making a Samba share on CentOS to make things easier.

So the first step is to actually install Samba which can be done by using:

yum install -y samba

Once Samba is installed you just need to edit the /etc/samba/smb.conf to add in the directory you want to share. I made a new user just for this one off set up which I will go over below.

First create a new user with a directory and set a password:

useradd -d /home/tmpshare -m tmpshare
passwd tmpshare

Now we need to edit the smb.conf using nano / vi or any other editor and add the information below to the bottom of the file:

nano /etc/samba/smb.conf
[tmpshare]
comment = temporary share
path = /home/tmpshare
public = no
valid users = tmpshare
writable = yes
browsable = yes
create mask = 0765

Once this has been done you need to restart the service with:

service smb restart

Now on the other server you can make a directory under /mnt and mount the share:

mkdir /mnt/share
mount -t cifs -o username=tmpshare //ip-or-hostname/tmpshare /mnt/share

If you have selinux enabled there are some extra steps needed, You can see if it is enabled by running sestatus.

chcon -R -t samba_share_t /home/tmpshare/
semanage fcontext -a -t samba_share_t /home/tmpshare/
setsebool -P samba_enable_home_dirs on

Another issue you could run into is the password not being accepted, There is a simple fix for this as well.

smbpasswd -a tmpshare

Published inBlogCode

2 Comments

  1. anil anil

    m trying to configure samba share on my droplet.

    i was able to start smb service and my testparm op for new share is as below

    [smbShare]
    path = /home/anilf/smbShare
    valid users = anilf
    read only = No
    create mask = 0765

    but when i am trying to map network drive from my win7 , it is not working

    • Jonathan Jonathan

      Hi Anil,

      I have sent you an email about this, It is possible that you need to open the firewall ports to allow the connection.

Leave a Reply

Your email address will not be published. Required fields are marked *

Link your latest blog post?