码迷,mamicode.com
首页 > 其他好文 > 详细

samba共享服务的实现

时间:2016-12-23 23:29:23      阅读:458      评论:0      收藏:0      [点我收藏+]

标签:samba

实现SMB共享


1、在samba服务器上安装samba包

    yum install samba  -y

2、创建samba用户和组

    [root@localhost ~]# groupadd  -r  amdin

    [root@localhost ~]# useradd –s  /sbin/nologin  -G admin  wang

    [root@localhost ~]# smbpasswd  -a wang    #设置密码

    [root@localhost ~]# useradd –s /sbin/nologin mage   #mage用户不加入组是有理由的下面有介绍

    [root@localhost ~]# smbpasswd –a mage

    [root@localhost ~]# 

3、创建samba共享目录,并设置selinux

    [root@localhost ~]# mkdir /apps/test

    [root@localhost ~]# chgrp admin  /apps/test

    [root@localhost ~]# chmod 2775 /apps/test #那个2是特殊权限意思是此目录有写权限的用户在此目录中创建的文

件所属的组为此目录的属组

    如果应禁止selinux则不比执行以下命令。

    [root@localhost ~]# semanage fcontext  -a –t samba_share_t  ‘/apps/test(/.*)?’

    [root@localhost ~]# restorecon –vvFR /apps/test

4、Samba服务器配置

    [root@localhost ~]#vim /etc/samba/smb.conf

    security  =  user

    passdb backend  =  tdbsam

    [gongxiang]

    path  =  /apps/test

    write  list  =  @admin #再次用户组内的用户具有写权限,例如mage用户则没有。

    service  smb  restart  #重启服务可以测试使用

  

5、客户端访问

    安装包 

        yum install cifs-utils  -y

    查看samba服务器上的共享

    假设没有smbclient命令请使用yum install samba-client –y 命令安装

  root@centos7_1 gx]# smbclient -L 172.16.250.90 -U wang
  Enter wang‘s password:    #输入上文设置的密码
  Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.6.23-36.el6_8]
  Sharename       Type      Comment
  ---------       ----      -------
  gongxiang       Disk       # (samba服务器上的共享目录,这里显示的是共享名称)
  IPC$            IPC       IPC Service (Samba Server Version 3.6.23-36.el6_8)
  wang            Disk      Home Directories   #wang的家目录也共享了
  Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.6.23-36.el6_8]
  Server               Comment
    ---------            -------

    Workgroup            Master
    ---------            -------

6、用wang用户挂载smb共享并访问

    [root@centos7_1 ~]# mkdir /mnt/gx

    [root@centos7_1 ~]#mount -o username=wang  //172.16.250.90/gongxiang  /mnt/gx 

    [root@centos7_1 ~]#touch 123     #touch 123文件测试权限

    同理用mage用户挂载访问同上。


本文出自 “秋季” 博客,请务必保留此出处http://lxlxlx.blog.51cto.com/3363989/1885447

samba共享服务的实现

标签:samba

原文地址:http://lxlxlx.blog.51cto.com/3363989/1885447

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!