首页 > 系统相关 >Ubuntu 22.04 Samba 安装和配置

Ubuntu 22.04 Samba 安装和配置

时间:2023-07-19 12:55:07浏览次数:39  
标签:samba 22.04 create mask Samba Ubuntu yes 权限 SMB

安装

安装

sudo apt install samba

检查服务状态

systemctl status smbd --no-pager -l

检查是否启用(开机自启动)

systemctl is-enabled smbd
# enable it if inactive
systemctl enable smbd

配置

(可选)添加用户

sudo usermod -aG sambashare [username]

设置密码

sudo smbpasswd -a [username]

创建公开共享(可匿名访问)

sudo vi /etc/samba/smb.conf

按以下格式创建内容

[public]
  comment = public anonymous access
  path = /data/
  browsable =yes
  create mask = 0660
  directory mask = 0771
  writable = yes
  guest ok = yes

说明:

  1. [public]方括号内为share后显示的目录名
  2. path = /data/ 为用于share的本地路径
  3. browsable =yes 是否可以浏览
  4. create mask = 0660
  5. directory mask = 0771
  6. writable = yes是否可写
  7. guest ok = yes是否允许匿名访问

配置项

Samba可以配置的属性可以参考 https://www.samba.org/samba/docs/using_samba/ch08.html

create mask

八进制数, 每个数 3-bit 代表一组权限[rwx], 整个mask 代表 smb 客户端在创建文件时可以设置哪些bit.
默认是 0744, 对应[--- rwx r-- r--] 这代表着 unix 下的文件所有者可以 rwx [读,写,执行], 同组用户和其它可以 r [读]

对于下面的例子, create mask 限制从 smb 创建文件/目录时, 不管来自于什么客户端, 文件和目录的最大权限为 744

[data]
    path = /home/samba/data
    browseable = yes
    guest ok = yes
    writeable = yes
    create mask = 744

If you need to change it for nonexecutable files, we recommend 0644, or rw-r--r--.

Keep in mind that the execute bits can be used by the server to map certain DOS file attributes, as described earlier. If you're altering the create mask, those bits have to be part of the create mask as well.

directory mask

与create mask 相同, 八进制数, 每个数 3-bit 代表一组权限[rwx], 整个mask 代表 smb 客户端在创建目录时可以设置哪些bit.
默认是0744, 对应 [--- rwx r-- r--], 允许所有用户读, 但是只允许所有者自己浏览和修改. 建议改为 0750, [--- rwx r-x ---], 避免所有人可以访问

下面的例子中, 从客户端创建的目录, 最大权限为 755

[data]
    path = /home/samba/data
    browseable = yes
    guest ok = yes
    writeable = yes
    directory mask = 755

force create mode

这个配置项用于 当文件权限发生变化时强制设置的权限位. 常用于设置文件默认的组权限. 这个配置也可以用于设置 DOS 属性: archive (0100), system (0010), or hidden (0001).

TIP

有些windows应用保存文件时, 会创建一个带.bak后缀的文件, 当这些文件在samba共享目录下时, 所有者不一定是当前用户, 为了让当前用户还可以编辑修改, 可以设置 force create mode = 0660 , 这样可以保证新文件也可以被同组用户编辑.

force directory mode

这个配置项用于 当目录权限发生变化时强制设置的权限位. 常用于设置组权限, 默认为 0000.

force group

这个配置用于给所有连接上的客户端, 只要客户端成功通过验证, 都会被指定一个固定的分组. 这个分组会体现在新创建的文件和目录上.

force user

同样的, 这个配置会给连接上的验证通过的客户端, 指定一个用户, 体现在新创建的文件和目录上.

关于 CIFS 和 SMB 的选择

In this day and age, you should always use the acronym SMB. I know what you’re thinking – “but if they’re essentially the same thing, why should I always use SMB?”

Two reasons:

  1. The CIFS implementation of SMB is rarely used these days. Under the covers, most modern storage systems no longer use CIFS, they use SMB 2 or SMB 3. In the Windows world, SMB 2 has been the standard as of Windows Vista (2006) and SMB 3 is part of Windows 8 and Windows Server 2012.
  2. CIFS has a negative connotation amongst pedants. SMB 2 and SMB 3 are massive upgrades over the CIFS dialect, and storage architects who are near and dear to file sharing protocols don’t appreciate the misnomer. It’s kind of like calling an executive assistant a secretary.

参考

标签:samba,22.04,create,mask,Samba,Ubuntu,yes,权限,SMB
From: https://www.cnblogs.com/milton/p/17565297.html

相关文章

  • Ubuntu安装MySQL、nginx、nacos
    Ubuntu安装mysql1、安装mysql#此命令直接安装最新版mysql8.0sudoapt-getinstallmysql-server2、查看默认用户及密码cat/etc/mysql/debian.cnfuser =debian-sys-maintpassword =s8hjWltF0W2EBU323、登录该用户mysql-udebian-sys-maint-pusemysql;updateuse......
  • ubuntu 不能直接打开终端,只能在目录下才能打开
    原本python版本为3.10,后来增加3.8和3.9,pyhton指向了python3.9,从而导致ubuntu不能直接打开终端,只能在目录下才能打开输入命令sudognome-terminal,会报以下错误:Traceback(mostrecentcalllast):File"/usr/bin/gnome-terminal",line9,in<module>fromgi.reposit......
  • 八万乌云漏洞库——Ubuntu本地Docker搭建环境
    环境准备ubuntu16.04虚拟机换国内源vi/etc/apt/sources.list阿里源debhttp://mirrors.aliyun.com/ubuntu/xenialmaindeb-srchttp://mirrors.aliyun.com/ubuntu/xenialmaindebhttp://mirrors.aliyun.com/ubuntu/xenial-updatesmaindeb-srchttp://mirrors.aliy......
  • Mobax ssh 连接 Ubuntu 虚拟机
    1.ConnectionRefused虚拟机检查ssh是否安装ps-e|grepssh安装openssh-serversudoapt-getinstallopenssh-server2.使用root登录后,提示Accessdenied修改/etc/ssh/sshd_configPermitRootLoginyes然后重启服务https://blog.csdn.net/haolvshiqi/article/......
  • ubuntu16.04安装qdrant向量数据库
    qdrant向量数据库目前只支持docker部署1、安装docker(如果已经安装,跳过)在服务器上安装一下docker,下面是在ubutnu下安装docker1aptupdate2aptinstallapt-transport-httpsca-certificatescurlgnupglsb-release3curl-fsSLhttps://download.docker.com/linux/ubuntu/......
  • ubuntu 22.04离线安装cuda 11.7.1、cudnn 8.9.3.28、nccl 2.18.3、tensorrt 8.6.1
    最近在使用飞桨OCR,有几个特殊的符号需要进行识别,手上只有两台机器,一台1080TI单卡(windows11),一台1080Ti双卡(linux22.04),习惯性追新到飞桨最高支持的cuda11.7,其实1080Ti到cuda10就够用了,后面的新版本差没有明显的性能提升。windows上无脑安装,linux上安装比较麻烦,记录下安装过程......
  • ubuntu 22.04 中文输入法,最后是googlepinyin拯救了我!
    installgooglepinyinsudoapt-getinstallfcitx-googlepinyin另外记得去设置系统默认输入法:settings->Region&Language->ManageinstalledLanguages->Keyboardinputmethodsystem:Fcitx4配置/etc/environment(升级到22.04之后的关键一步,必须得配置,我安装好......
  • 给vmware,ubuntu22配置桥接网络,并设置固定ip
    1、设置桥接网络      2、配置固定ip 2.1、确认版本,不同版本的linux配置的位置及文件是不同的root@ubuntu:/#lsb_release-a#进入虚拟机NoLSBmodulesareavailable.DistributorID:UbuntuDescription:Ubuntu22.04.2LTSRelease:22.04Coden......
  • 搭建远程开发环境@Win11+OpenWrt+Vscode+WSL2+Ubuntu22.04
    Pre之前618从pdd上买了配件,第一次尝试自己组装了电脑,本意是作为炼丹炉,不过毕竟是自己的电脑不像服务器可以一天到晚打黑工,还是用来开发就好,测测代码跑跑ai。没显示器——远程连接(后来还是买了,而且今天才发现买的那款大降价,唉),没键鼠——远程连接,没网络——二手路由刷openwrt去中......
  • ubuntu20.04使用plx9054官方驱动 转载
    转载地址http://wuhongyi.cn/PKUXIADAQ/en/INSTALL.htmlInstallationofSoftwareInstallationforthissoftwareisrequriredbyCERNROOT6GCC>=4.8FFTW3OPENSSLTheoperatingsystemtestedbythisprogramincludesCentOS7/ScientificLinux7/......