当前位置:首页 > 系统 > Linux > 正文内容

AnolisOS8/CentOS8安装samba

1年前 (2022-12-29)Linux1136
[TOC]

安装samba服务

yum install samba -y

备份默认配置smb.conf

cd /etc/samba/ 
cp smb.conf smb.conf.bak #备份一下配置文件

无需认证匿名访问

vi 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
    #?使用smb v1,根据需要选择,我的小米cam需要用v1才可以认上
    client min protocol = NT1
    server min protocol = NT1
[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

[smbshare]
#无需认证匿名访问配置
        path=/data2/samba/mi_cam/    #共享路径
        public=yes    #公共
        browseable=yes    #读权限
        writable=yes    #写权限
        create mask=0644    #设置权限
        directory mask=0755

所设置的访问路径需要先创建并设置权限

mkdir -p /data2/samba/mi_cam/
chmod 777 /data2/samba/mi_cam/

启动服务

systemctl start smb.service

用户验证才可访问

创建samb用户和密码

useradd mi-cam    #创建用户mi-cam
smbpasswd -a mi-cam    #设置用户mi-cam的smb登录密码
vi 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
    #?使用smb v1,根据需要选择,我的小米cam需要用v1才可以认上
    client min protocol = NT1
    server min protocol = NT1
[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

[smbshare]
#指定才可用户访问配置
        path=/data2/samba/mi_cam/    #共享路径
        browseable=yes 
        create mask=0644    #设置权限
        directory mask=0755
        valid users=mi-cam    #可读用户
        write list=mi-cam    #可写用户

保存后重启服务

systemctl restart smb.service
systemctl restart nmb.service

访问和挂载

Linux访问SMB

smbclient -L //10.0.0.98/share  #访问共享

Linux挂载SMB

mount.cifs //10.0.0.98/share /tmp/smbtest  #将SMB共享文件夹挂载到/tmp/smbtest

扫描二维码推送至手机访问。

版权声明:本文由豆子林克发布,如需转载请注明出处。

除特别申明外,本站原创内容版权遵循 CC-BY-NC-SA 协议规定 

本文链接:https://www.douzi.link/post/757.html

分享给朋友:
返回列表

上一篇:CentOS 7 Tesla P4 GPU驱动安装

没有最新的文章了...

相关文章

Centos重启/关机命令

Centos重启命令: 1、reboot   普通重启 2、shutdown -r now 立刻重启(root用户使用) 3、shutdown -r 10 过10分钟自动重启(root用户使用) 4、shutdown -r 20:3...

常用文件处理命令-文件处理命令

touch 创建文件,Linux文件名可以是任何(不局限于.png/.conf/.cnf这样的) cat 显示文件内容,参数:-n显示行号 tac 倒序显示文件内容,就是将“cat”反过来 more 显示文件内容可向下翻...

权限管理命令chmod

命令名称:chmod 命令所在路径:/bin/chmod 执行权限:所有用户 语法:chmod[{ugoa}{+-=}{rwx}][文件或目录] chmod[mode=421][文件或目录] -R 递归修改...

添加用户命令

功能:添加用户 示例:#useradd username  //添加用户   #userdel username  //删除用户,如果用户处在活动状态需要先注销在删除 &nbs...

文件搜索命令find

命令名称:find 命令所在路径:/bin/find 执行权限:所有用户 语法:find [搜索范围][匹配条件] 功能描述:文件搜索   示例: 在目录/etc中查找文件init,lin...

文件搜索命令-压缩解压缩命令

命令名称:压缩gzip 解压缩:gunzip **不能压缩目录 语法:gzip/gunzip[文件/压缩文件] 范例:$gzip noke 压缩文件noke $gunzip noke.gz 解压缩文件noke.gz &nbs...

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。