Samba as a file server as a member of a domain

Hello community, I have been fixing one of my shared folder servers in windows that has crashed due to problems with a virus 🙁

To solve this I have set up a samba as a file server and member of my domain. This is the procedure that I have followed and it works properly for my needs.

Samba as a file server in Ubuntu 14.04

The steps to be carried out are the following

  • Install and configure ntp

sudo apt install ntp

  • Edit ntp.conf with the data below:

sudo nano /etc/ntp.conf

#################################### driftfile /var/lib/ntp/ntp.drift statistics loopstats peerstats clockstats filegen loopstats file loopstats type day enable filegen peerstats file peerstats type day enable filegen clockstats file clockstats type day enable server miserverntp.mydomain.cu restrict -4 default kod notrap nomodify nopeer restrict -6 default kod notrap nomodify nopeer restrict 127.0.0.1 restrict :: 1 restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap broadcast 172.16.1.224 broadcast 192.168.1.255 tos orphan server 127.127.1.0 fudge 127.127.1.0 stratum 8 ################# ############################
  • Create script to sync with public ntp

sudo nano ntp.sh

The data to be included in the script are the following:

####################################### #! / bin / bash sudo service ntp stop sudo ntp -gq sudo service ntp start ########################################## #####
  • Next we create a task to run sync periodically:

sudo nano /etc/crontab

########################################### 20 0 * * * root /home/ladmin/ntp.sh ########################################## ##
  • Let's verify that the system time is correct

date

  • We edit the samba configuration with the following data

sudo nano /etc/samba/smb.conf

############################################# # in this global case and folder do not have quotes, but I have not found a way to get the #brackets :-p "[global]" netbios name = data1 workgroup = DOMAIN security = ADS realm = SAMBA.DOMINIO.CU encrypt passwords = yes idmap config * : backend = rid idmap config *: range = 100000-200000 winbind use default domain = yes winbind enum users = yes winbind enum groups = yes vfs objects = acl_xattr map acl inherit = Yes store two attributes = Yes log level = 1 log file = /var/log/samba/samba.log "[folder]" comment = folder path = / home / samba / folder browseable = Yes read only = No force create mode = 0660 force directory mode = 0660 vfs objects = acl_xattr full_audit full_audit: prefix =% u |% I |% S full_audit: facility = local7 full_audit: success = mkdir rename unlink rmdir pwrite open full_audit: failure = none full_audit: priority = NOTICE ################ ###############################
  • Then you must join the domain

net ads join -U usuario_admin_de_dominio

  • To verify that the domain was successfully joined, we use these 2 commands
wbinfo -u getent passwd
  • The corresponding samba folders are created

mkdir /home/samba/

Create folder that we will see as a shared resource
mkdir /home/samba/carpeta

  • In my case I set the permissions in samba with 777, you should keep in mind that in some cases this is a security risk, so this step is optional

chmod 777 -R /home/samba

  • We proceed to install windbind and cifs-utils

sudo apt install libnss-winbind cifs-utils

  • Edit the file /etc/nsswitch.conf and add (replace) this
passwd: compat winbind group: compat winbind
  • We restart the PC

Well, for the moment we already have the server working, we can create folders and modify the permissions from the same windows.

I hope it is useful to you, any questions or suggestions will be accepted.

Remember, always attack ideas and not people.

Greetings from Havana



		

Leave a Comment

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

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Federico said

    Hello, very good tutor, ask, do you have the steps to follow to do the same but in Centos 7?
    From already thank you very much!

    Atte.

    Frederick.

    1.    revenge said

      I've only used it on Debian 7 and Ubuntu 14.04 🙁. But I guess it shouldn't be too difficult in Centos