Samba的配置,安装和Windows访问
QQQ 文件系统 27

#什么是Samba?
Samba是一种用于在局域网共享文件和打印机的一种通信协议,切实C/S类型的协议,可以通过设置NetBios Over TCP/IP使得其能被公网访问。

#怎么安装?
一般来说,各家平台都提供了Samba安装包,相当简便。

#Samba配置文件
OpenWrt:/etc/config/samba

  • Configuring the samba service: "config samba" section of /etc/config/samba
  • Configuring a samba share: "config sambashare" section of /etc/config/samba(两种level的访问,share level和user level)
  • Adding samba user(s):To access a samba share with user level access there must be users added to the system by editing /etc/passwd
  • Adding a password for each samba user:smbpasswd -a newuser(The passwords get stored in hashed form in /etc/samba/smbpasswd.)
    Centos
  • /etc/samba/smb.conf:主要配置文件,若不在通过locate或者find查找吧。
  • /etc/samba/lmhosts:这个档案的主要目的在对应 NetBIOS name 与该主机名的 IP ,事实上他有点像是 /etc/hosts 的功能!只不过这个 lmhosts 对应的主机名是 NetBIOS name 喔!不要跟 /etc/hosts 搞混了!由于目前 SAMBA 的功能越来越强大,所以通常只要您一启动 SAMBA 时,他就能自己捉到 LAN 里面的相关计算机的 NetBIOS name 对应 IP 的信息,因此这个档案通常可以不用设定了!
  • /etc/samba/smbpasswd:这个档案预设并不存在啦!他是 SAMBA 默认的用户密码对应表。当我们设定的 SAMBA 服务器是较为严密的,需要用户输入账号与密码后才能登入的状态时,用户的密码默认就是放置在这里咯 (当然啰,您可以自行在 smb.conf 里面设定密码放置的地方及密码文件名, 不过我们这里都以预设的状态来说明) 。比较需要注意的是,这个档案因为包含了用户的密码, 当然权限方面要较为注意啦!这个档案的拥有者需要是 root ,且权限设定为 600 才行喔!
  • /etc/samba/smbusers:由于 Windows 与 Unix-like 在管理员与访客的账号名称不一致,分别为 administrator 及 root, 为了对应这两者之间的账号关系,可以使用这个档案来设定。不过这个档案的使用必须要经由 smb.conf 内的『 username map 』设定项目来启动才行。
  • testparm:检验samba配置语法是否正确
  • smbstatus:检测状态
  • smbpasswd:设置密码
  • smbmount:挂载至本地
  • nmblookup:类似于nslookup,查NetBIOS name
  • smbtree:查分布

#Windows11如何访问?

#若设置完全无安全则把security设置为share,from user to share
\\IP\Path_To_YourDirectory

Cannot write to the Samba share

If you cannot write to the share, Samba may not have the proper permissions to write to the shared folder.

Some have reported success by modifying the permissions and owner of the folder:

chmod -R 777 /mnt/sda1
chown -R nobody /mnt/sda1

Samba的配置,安装和Windows访问
https://blog.427221.xyz/archives/samba%E7%9A%84%E9%85%8D%E7%BD%AE%E5%92%8C%E5%AE%89%E8%A3%85
作者
qqq
发布于
更新于
许可