Linux build service deployment -2 samba server time

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/Tiger_lin1/article/details/87827369

First, install Samba service

yum -y install samba

View yum source version of Samba

yum list | grep samba

Check installation of samba

rpm -qa | grep samba

After Samba server is installed, generates the configuration files in the directory / etc / samba, /etc/samba/smb.conf the samba is the core configuration file.
Second, start the Samba service

There are two ways to start the Samba service after the installation is complete:

service smb start/stop/restart/status

# 或者
systemctl start/stop/restart/status smb.service

# 设置smb服务开机启动
systemctl enable smb.service

Third, the Samba open service port number to use
Samba service will use some of the following port numbers:
137 (UDP): the NetBIOS name service
138 (UDP): NetBIOS datagram service
139 (TCP): File and Print Sharing
389 (TCP ): for the LDAP
445 (TCP): the NetBIOS service in windows 2000 and later use this port
901 (TCP): for SWAT, Samba web management
if you do not turn off the firewall, then we would open in the CentOS Samba to use TCP The port number

    firewall-cmd --zone=public -add-port=139/tcp --permanent
    firewall-cmd --zone=public -add-port=389/tcp --permanent
    firewall-cmd --zone=public -add-port=445/tcp --permanent
    firewall-cmd --zone=public -add-port=901/tcp --permanent
    
    firewall-cmd --reload

# 查看已经放开的端口号

    firewall-cmd --list-all

Fourth, the Samba service configuration
1, configure anonymous access, a shared directory accessible to anyone

  1. Create a shared directory

    mkdir /opt/shares

    Because the need to set up anonymous users can upload and download files, so nobody needs to grant permission to the directory shares

chown -R nobody:nobody /opt/shares

  1. Modify /etc/samba/smb.conf file

    cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
    we /etc/samba/smb.conf

Modify the configuration is as follows:

    # See smb.conf.example for a more detailed config file or
    # read the smb.conf manpage.
    # Run 'testparm' to verify the config is correct after
    # you modified it.

[global]
        workgroup = SAMBA
        security = user
        map to guest = Bad User
        log file = /var/log/samba/log.%m


[public]
        comment = Public Stuff
        path = /opt/shares
        public = yes
        read only = No

Where path is set on top of the shared directory, read only indicate whether or not you have write access

  1. Samba restart the service after completing modify the configuration file

    systemctl restart smb.service

  2. Testing smb.conf configuration is correct

    Use testparm command

    testparm

  3. At this point it is configured, you can access the samba shared directory from Windows.

2, the configuration designated users can access the shared directory
set shared directory, only allow the user access to the specified user group
1) was added and the Working Group Linus user Linus1

 [ root@localhost ~]# groupadd linus
    
    # useradd -g 组名 用户名
    
        [root@localhost ~]# useradd -g linus linus1
    
    # 设置用户Linus1的密码
    
        [root@localhost ~]# passwd linus1
    
    #删除用户
    userdel -r 用户名
  1. To add an account to access samba's account
    optical add the system account is not enough, you need to add to the already existing system account can access the samba shared directory

    smbpasswd parameters: -a: add -x: Delete -d: Disable -e: Enable

    [root@localhost ~]# smbpasswd -a linus1

  2. Create a shared directory

    [root@localhost ~]# mkdir /opt/shares1

    chown -R Username: group name directory

    [root@localhost ~]# chown -R linus1:linus /opt/shares1

  3. Set samba service
    modify the configuration file /etc/samba/smb.conf as follows

     # See smb.conf.example for a more detailed config file or
     # read the smb.conf manpage.
     # Run 'testparm' to verify the config is correct after
     # you modified it.
     
     [global]
             workgroup = SAMBA
             security = user
             map to guest = Bad User
             log file = /var/log/samba/log.%m
     
     [public]
             comment = Public Stuff
             path = /opt/shares
             public = yes
             read only = No
     [shares]
             comment = LINUS
             path = /opt/shares1
             # 表示用户组
             valid users = @LINUS
             read only = No
    
  4. Restart the smb service

    systemctl restart smb.service

Check that the correct configuration file smb.conf

testparm
  1. At this point the configuration is complete, you can access the shared directory by the username share / share on the Windows platform.

Guess you like

Origin blog.csdn.net/Tiger_lin1/article/details/87827369