• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
 






头条号:西西图图(美食运维)

 
 

Powered by 博客园
博客园 | 首页 | 新随笔 | 联系 | 订阅 订阅 | 管理

linux下samba共享服务器搭建详解

这两天业务需求搭了一台服务器。要求samba共享文件。

葡萄美酒月光杯的前戏就省了,我们直接上干货。

1、yum方式安装samba

yum  -y  install samba

2、将/etc/samba/smb.conf文件备份一个(个人习惯,不备份也是可以的)

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

3、修改对应文件

 

[root@ceshi01-10 samba]# cat smb.conf
# 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

        passdb backend = tdbsam

        printing = cups
        printcap name = cups
        load printers = yes
        cups options = raw
        map to guest = bad user      #在centos7之后都要加这一行了
        hosts allow=192.168.10.21  192.168.10.22       #只允许某些ip访问这台samba服务器;多个ip之间用空格隔开即可;如果允许某一个网段的话,可以这样:192.168.10.0/24

[homes]
        comment = Home Directories
        valid users = %S, %D%w%S
        browseable = No
        read only = No
        inherit acls = Yes

[printers]
        comment = All Printers
        path = /var/tmp
        printable = Yes
        create mask = 0600
        browseable = No

[print$]
        comment = Printer Drivers
        path = /var/lib/samba/drivers
        write list = @printadmin root
        force group = @printadmin
        create mask = 0664
        directory mask = 0775

[myshare]          #这是samba共享文件的一个名词;自己可以随便起个123都行,但最好起得有点代表性
        comment = yang share    #这个comment后面的文字是对这个samba的解释
        path = /data        #path是要分享的路径,记住,这路径一定要给到合适权限,不然访问会出错的。
        writable = yes      #决定访问的用户能否写入文件
        guest ok = yes       #决定访客用户能否访问
        browseable = yes    #出于安全考虑,有时会让客户端无法看到某个共享目录,这样只有管理员或者一些重要人士知道Samba服务器上有这样一个目录,而其它人员并不知道这个目录。
[root@ceshi01-10 samba]#

 

4、要记得服务器的防火墙一定要关闭;或者开通防火墙权限才行。

 

5、服务器端安装samba客户端

yum install cifs-utils

mount -t cifs -o username="root",password="" //ip/共享文件夹名字 /挂载点

列如:

mount -t cifs -o username="root",password="p" //192.168.10.20/myshare /mnt

[root@ceshi02-10 ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   17G  7.9G  9.2G  47% /
devtmpfs                 898M     0  898M   0% /dev
tmpfs                    910M     0  910M   0% /dev/shm
tmpfs                    910M  9.6M  901M   2% /run
tmpfs                    910M     0  910M   0% /sys/fs/cgroup
/dev/sda1               1014M  146M  869M  15% /boot
tmpfs                    182M     0  182M   0% /run/user/0
//192.168.10.20/myshare   17G  1.4G   16G   8% /mnt
[root@ceshi02-10 ~]# vf mnt

 

6、如果是windows访问的话

直接windows+R的弹窗输入\\192.168.10.20就可以了。

发表于 2019-05-30 09:39  头条号-西西图图  阅读(1072)  评论(0)    收藏  举报
 
刷新页面返回顶部