samba文件共享服务的配置

服务端配置

一、安装samba软件包

命令:yum -y install samba

查看是否安装samba。

 [root@Centos7-Server haha]#
[root@Centos7-Server haha]# rpm -qa |grep "samba"
samba-common-tools-4.8.-.el7.x86_64
samba-client-libs-4.8.-.el7.x86_64
samba-4.8.-.el7.x86_64
samba-common-libs-4.8.-.el7.x86_64
samba-client-4.8.-.el7.x86_64
samba-libs-4.8.-.el7.x86_64
samba-common-4.8.-.el7.noarch
[root@Centos7-Server haha]#

二、修改配置文件/etc/samba/smb.conf

 [root@Centos7-Server haha]# vim /etc/samba/smb.conf

         passdb backend = tdbsam

         printing = cups
printcap name = cups
load printers = yes
cups options = raw [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 =
browseable = No [print$]
comment = Printer Drivers
path = /var/lib/samba/drivers
write list = @printadmin root
force group = @printadmin
create mask =
directory mask =
[common]
path = /common
#read only =No
write list = yck [sharetest]                 #自定义名称
path = /sharetest # 共享目录的路径
write list = yck #允许yck用户具有写的权限,当用yck用户认证访问共享目录时,如果想在共享目录中创建删除,需要将认证的用户添加到这里。

三、创建共享的目录/sharetest,并配置acl定制权限。yck用户可读可写可执行。为yck用户创建samba认证密码。

[root@Centos7-Server /]#
[root@Centos7-Server /]#
[root@Centos7-Server /]# pdbedit -a yck
new password:
retype new password:
Unix username: yck
NT username:
Account Flags: [U ]
User SID: S-------
Primary Group SID: S-------
Full Name: yck
Home Directory: \\centos7-server\yck
HomeDir Drive:
Logon Script:
Profile Path: \\centos7-server\yck\profile
Domain: CENTOS7-SERVER
Account desc:
Workstations:
Munged dial:
Logon time:
Logoff time: Wed, Feb :: CST
Kickoff time: Wed, Feb :: CST
Password last set: Wed, Apr :: CST
Password can change: Wed, Apr :: CST
Password must change: never
Last bad password :
Bad password count :
Logon hours : FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
[root@Centos7-Server /]#
[root@Centos7-Server /]#
 [root@Centos7-Server /]# mkdir sharetest                                           #创建sharetest目录 [root@Centos7-Server /]# setfacl -m u:yck:rwx sharetest/                           #配置acl,yck对sharetest目录具有rwx权限 [root@Centos7-Server /]# ll
total
lrwxrwxrwx. root root Apr : bin -> usr/bin
dr-xr-xr-x. root root Apr : boot
drwxr-xr-x. root root Apr : common
drwxr-xr-x. root root Apr : dev
drwxr-xr-x. root root Apr : etc
drwxr-xr-x. root root Apr : home
lrwxrwxrwx. root root Apr : lib -> usr/lib
lrwxrwxrwx. root root Apr : lib64 -> usr/lib64
drwxr-xr-x. root root Apr media
drwxr-xr-x. root root Apr : mnt
drwxr-xr-x. root root Apr : opt
dr-xr-xr-x. root root Apr : proc
dr-xr-x---. root root Apr : root
drwxr-xr-x. root root Apr : run
lrwxrwxrwx. root root Apr : sbin -> usr/sbin
drwxrwxr-x+ root root Apr : sharetest #+表示具有其他的权限配置
drwxr-xr-x. root root Apr srv
dr-xr-xr-x. root root Apr : sys
drwxrwxrwt. root root Apr : tmp
drwxr-xr-x. root root Apr : usr
drwxr-xr-x. root root Apr : var
[root@Centos7-Server /]#

四、selinux配置samba的读写功能的开启

查看samba的读写功能是否开启。

 [root@Centos7-Server /]#
[root@Centos7-Server /]# getsebool -a |grep "samba"
samba_create_home_dirs --> off
samba_domain_controller --> off
samba_enable_home_dirs --> off
samba_export_all_ro --> off                       #读权限关闭
samba_export_all_rw --> off #写权限关闭
samba_load_libgfapi --> off
samba_portmapper --> off
samba_run_unconfined --> off
samba_share_fusefs --> off
samba_share_nfs --> off
sanlock_use_samba --> off
tmpreaper_use_samba --> off
use_samba_home_dirs --> off
virt_use_samba --> off
[root@Centos7-Server /]#

开启读写功能

 [root@Centos7-Server /]#
[root@Centos7-Server /]# setsebool samba_export_all_ro on
[root@Centos7-Server /]# setsebool samba_export_all_rw on
[root@Centos7-Server /]# getsebool -a |grep "samba"
samba_create_home_dirs --> off
samba_domain_controller --> off
samba_enable_home_dirs --> off
samba_export_all_ro --> on
samba_export_all_rw --> on
samba_load_libgfapi --> off
samba_portmapper --> off
samba_run_unconfined --> off
samba_share_fusefs --> off
samba_share_nfs --> off
sanlock_use_samba --> off
tmpreaper_use_samba --> off
use_samba_home_dirs --> off
virt_use_samba --> off
[root@Centos7-Server /]#

五、防火墙(将默认区域设置为trusted)

 [root@Centos7-Server /]#
[root@Centos7-Server /]# firewall-cmd --set-default-zone=trusted
success
[root@Centos7-Server /]# firewall-cmd --get-default-zone
trusted
[root@Centos7-Server /]#

六、挂载使用。

安装cifs-utils软件包,用于支持cifs协议。samba用cifs协议传输数据。

 [root@Centos7-Server /]#
[root@Centos7-Server /]# yum -y install cifs-utils
[root@Centos7-Server /]#
[root@Centos7-Server /]#
[root@Centos7-Server /]# mount -t cifs -o user=yck,pass= //192.168.0.50/sharetest /mnt
[root@Centos7-Server /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 36G .1G 32G % /
devtmpfs 895M 895M % /dev
tmpfs 910M 910M % /dev/shm
tmpfs 910M 11M 900M % /run
tmpfs 910M 910M % /sys/fs/cgroup
tmpfs 182M 182M % /run/user/
tmpfs 182M 12K 182M % /run/user/
//192.168.0.251/linux 62G 33G 30G 53% /root/share
//192.168.0.50/common 36G 4.1G 32G 12% /mnt
//192.168.0.50/sharetest 36G 4.1G 32G 12% /mnt
[root@Centos7-Server /]#
mount         -t            cifs      -o      user=yck,   pass=123    //192.168.0.50/sharetest       /mnt
命令 指定我文件系统类型 cifs文件系统 表示后面跟参数 用户名 密码 共享位置 挂载点

永久挂载,科技自动挂载。

 root@yck-virtual-machine:/#
root@yck-virtual-machine:/# cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab().
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda1 during installation
UUID=231caf54-bdcd-4a5b-b3a0-116b3b97ef51 / ext4 errors=remount-ro
/swapfile none swap sw
#/dev/sdb5 /home/yck/part ext4 defaults
#/dev/yck_vg/yck_data /home/yck/part ext4 defaults
//192.168.0.50/sharetest /mnt cifs defaults,user=yck,pass=123,_netdev 0 0 #挂载网络共享文件夹
root@yck-virtual-machine:/#
//192.168.0.50/sharetest                  /mnt            cifs    defaults,user=yck,pass=123,_netdev   0 0  
共享目录、共享位置 挂载点 文件系统 参数 用户名 密码 声明该挂载为网络设备 备份标记 不检测 测试、etc/fstab 里面的配置是否有误,挂载是否成功。
 root@yck-virtual-machine:/# mount -a
root@yck-virtual-machine:/#

mount -a  不报错表示配置文件无误,挂载成功。但必须先确保该挂载位置未事先挂载才能进行测试。不然不管怎么测都是不会报错的。

samba文件共享服务的配置的更多相关文章

  1. Linux基础学习-Samba文件共享服务

    使用Samba文件共享服务 Samba起源: 早期网络想要在不同主机之间共享文件大多要用FTP协议来传输,但FTP协议仅能做到传输文件却不能直接修改对方主机的资料数据,这样确实不太方便,于是便出现了N ...

  2. 红帽7配置samba文件共享服务

    samba软件主要功能是为客户机提供共享使用的文件夹. 使用的协议是SMB(TCP 139).CIFS(TCP445). 所需的软件包:samba 系统服务:smb 1.安装samba服务 ~]#yu ...

  3. Samba文件共享服务

    Samba起源: 早期网络想要在不同主机之间共享文件大多要用FTP协议来传输,但FTP协议仅能做到传输文件却不能直接修改对方主机的资料数据,这样确实不太方便,于是便出现了NFS开源文件共享程序:NFS ...

  4. nfs samba文件共享服务

    (注意:实验之前强关闭selinux和防火墙) 一丶nfs ① 1.服务端 启动服务 systemctl start nfs.service   配置文件 vim /etc/exports share ...

  5. SAMBA 文件共享服务

    samba 通过简单配置就能够实现Linux系统与Windows系统之间的文件共享工作,也可实现Linux与Linux之间的文件共享. 在配置samba前,有个小建议:虚拟机的ip地址最好配置成静态的 ...

  6. Samba文件共享服务设置

    SMB的主程序 smbd:SMB-TCP139,CIFS-TCP445 nmbd:NetBios-UDP137,138 SMB主程序对应的两个服务 /etc/init.d/smb /etc/init. ...

  7. Linux Samba文件共享服务,安装与案例配置

    Samba服务器安装和配置 1:安装Samba服务器软件包 [root@localhost ~]# rpm -qa | grep samba [root@localhost ~]# yum -y in ...

  8. samba文件共享服务配置一(共2节)

    一.samba服务简介 Samba是在Linux和UNIX系统上实现SMB协议的一个免费软件,由服务器及客户端程序构成.SMB(Server Messages Block,信息服务块)是一种在局域网上 ...

  9. 36.Samba 文件共享服务1--安装及配置参数解释

    1.Samba 服务程序现在已经成为在Linux 系统与Windows系统之间共享文件的最佳选择. 1)安装: [root@localhost ~]#yum install samba Loaded ...

随机推荐

  1. CSS之背景的填充范围

    1.资料:CSS2.1 进行了更正:元素的背景是内容.内边距和边框区的背景 2.也就是说背景颜色,background-color:这些会填充内边距和边框border, 而不会填充外边框margin的 ...

  2. ViewPager+fragment的使用

    如图我在一个继承FragmentActivity的类中嵌套了3个fragment分别能实现3个不同的界面,默认展现第一个,在第一个的fragment中有个ViewPager在ViewPager中嵌套了 ...

  3. constructor()方法

    在做微信小程序的时候,需要对传输的数据进行加密,大牛给我介绍constructor()方法,不是很懂这个但是用了一次,今天来用自己的想法来理解这个方法 ———————————————————————— ...

  4. github代码上传教程

    github 上传代码步骤 一.git以及Github Git是个正快速成长的版本控制系统,它由GitHub维护. 优势: 1.支持离线开发,离线Repository. 2.强大的分支功能,适合多个独 ...

  5. checkpoint(sqlserver数据库检查点)

    关于检查点的解释:   出于性能方面的考虑,数据库引擎对内存(缓冲区缓存)中的数据库页进行修改,但在每次更改后不将这些页写入磁盘.相反,数据库引擎定期发出对每个数据库的检查点命令.“检查点”将当前内存 ...

  6. June 13th 2017 Week 24th Tuesday

    There are no regrets in life, just lessons. 人生中没有后悔,只有教训. Some people can learn from their past mist ...

  7. May 25th 2017 Week 21st Thursday

    Follow your heart, but take your brain with you. 跟随你的内心,但是请别失去理智. I was ever told that we should fol ...

  8. c++中的const用法(很详细)——转

    http://www.cnblogs.com/ymy124/archive/2012/04/16/2451433.html const给人的第一印象就是定义常量. (1)const用于定义常量. 例如 ...

  9. 从产品展示页面谈谈Hybris系列之二: DTO, Converter和Populator

    文章作者:张健(Zhang Jonathan) 上一篇文章 从产品展示页面谈谈Hybris的特有概念和设计结构 我们讲解了Hybris一些特有的概念以及大体架构,并且介绍了Facade层里是如何定义D ...

  10. Django Request 与Response对象

    Django使用请求和响应对象在系统中传递状态.当请求页面时,Django创建一个HttpRequest对象,该对象包含关于请求的元数据. 然后Django加载适当的视图,将HttpRequest作为 ...