AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题

问题[samba](server)

Martin Hope
Etienne Charland
Asked: 2024-06-11 00:12:41 +0800 CST

SELinux 拒绝 samba 共享

  • 6

尝试配置 samba 以共享我的驱动器(本地到虚拟机)。使用 Fedora。

共享与 兼容sudo setenforce 0,因此这是 SELinux 问题

这是我的 SELinux 规则。

sudo semanage fcontext -l | grep samba
/home/hanuman(/.*)?                                all files          system_u:object_r:samba_share_t:s0 
/run/media/hanuman(/.*)?                           all files          system_u:object_r:samba_share_t:s0 

以下是日志

type=AVC msg=audit(1718035536.971:480): avc:  denied  { getattr } for  pid=7754 comm="smbd[192.168.1." path=2F72756E2F6D656469612F68616E756D616E2F53746F726167652D6E7466732F4D6F73742042656175746966756C204368696E65736520536F6E6720596F752077696C6C20457665722048656172203230313020323031352E6D7033 dev="sda1" ino=228609 scontext=system_u:system_r:smbd_t:s0 tcontext=system_u:object_r:fusefs_t:s0 tclass=file permissive=0

我错过了什么?

我注意到smbd_tvs samba_share_t,那有什么区别?

audit2allow -w -a建议setsebool -P samba_export_all_rw 1虽然可行,但不是最好的解决方案。

samba
  • 2 个回答
  • 120 Views
Martin Hope
Karl M. Davis
Asked: 2023-12-25 05:02:51 +0800 CST

Samba 的 smbd 不再使用 MIT Kerberos 和 OpenLDAP 进行身份验证

  • 6

我在尝试浏览 Samba 共享时收到以下错误:

session setup failed: NT_STATUS_NO_IMPERSONATION_TOKEN

我用于将独立服务器绑定smbd到 MIT Kerberos 和 OpenLDAP 设置的 Samba 配置曾经可以正常工作(在 Ubuntu 20.04 上确实如此,不记得在 Ubuntu 22.04 上是否也如此):

<smb.conf>

[global]
# Change this to the workgroup/NT-domain name your Samba server will part of
   workgroup = EXAMPLE

# The 'auto' setting here configures Samba based on the value of the
# 'security' setting.
   server role = auto

# Configure Samba to call out to Kerberos for all authentication. Because we're
# not also configuring a passdb, Samba will look to the system accounts for all
# authorization info (e.g. UIDs, groups, etc.). This setup was taken from
# https://help.ubuntu.com/lts/serverguide/samba-ldap.html.
   security = ads
   realm = EXAMPLE.COM
   kerberos method = dedicated keytab
   dedicated keytab file = /etc/samba/smbd.keytab

   idmap config * : backend = tdb
   idmap config * : range = 20001-30000
   idmap config {{ domain | upper }} : backend = rfc2307
   idmap config {{ domain | upper }} : range = 10000-20000

然后我可以获取 Kerberos 票证并浏览和/或挂载 Samba 共享,例如:

$ kinit
Password for [email protected]: 

$ /usr/bin/smbclient //neatbox.example.com/share --use-kerberos=required --no-pass --directory somepath --command ls
  .                                   D        0  Fri May  6 07:10:08 2022
  ..                                  D        0  Fri May  6 07:10:08 2022
  stuff                               D        0  Fri May  6 07:10:08 2022
  otherstuff                          D        0  Fri May  6 07:10:13 2022

        957134040 blocks of size 1024. 620537476 blocks available

然而,很久以前,这种方法就不再起作用了(比如一两年前;只是直到现在才有时间坐下来大惊小怪;养育子女,就像很多,你知道吗?)。现在我明白了:

$ /usr/bin/smbclient //neatbox.example.com/share --use-kerberos=required --no-pass --directory somepath --command ls
session setup failed: NT_STATUS_NO_IMPERSONATION_TOKEN

我现在花了几个晚上研究,我认为 Samba 4.14 周围有什么东西坏了或者被删除了?关于 PAC 的一些事情,它显然是 Kerberos 票证的一部分......不知何故?[1,2,3] 我不知道,我不是 Kerberos 专家;像大多数人一样,我只是在键盘上敲打一些东西,直到一切正常为止。

所以这是我的主要问题:Samba 是否像以前一样支持通过 MIT Kerberos 和 OpenLDAP 进行身份验证,或者现在已弃用/不受支持?

杂项

在启动/重新启动后,日志smbd中始终包含以下内容:

$ sudo systemctl status smbd
...
Dec 24 20:53:29 eddings systemd[1]: Starting Samba SMB Daemon...
Dec 24 20:53:29 eddings smbd[782101]: [2023/12/24 20:53:29.593145,  0] ../../source3/smbd/server.c:1734(main)
Dec 24 20:53:29 eddings smbd[782101]:   smbd version 4.15.13-Ubuntu started.
Dec 24 20:53:29 eddings smbd[782101]:   Copyright Andrew Tridgell and the Samba Team 1992-2021
Dec 24 20:53:29 eddings systemd[1]: Started Samba SMB Daemon.
Dec 24 20:53:30 eddings smbd[782101]: [2023/12/24 20:53:30.244701,  0] ../../source3/printing/nt_printing.c:233(nt_printing_init)
Dec 24 20:53:30 eddings smbd[782101]:   nt_printing_init: error checking published printers: WERR_ACCESS_DENIED

有时,不可重复地,它也会导致一堆以下错误:

Dec 24 11:06:27 eddings smbd[766136]: [2023/12/24 11:06:27.972690,  0] ../../source3/auth/auth_winbind.c:120(check_winbind_security)
Dec 24 11:06:27 eddings smbd[766136]:   check_winbind_security: winbindd not running - but required as domain member: NT_STATUS_NO_LOGON_SERVERS

不确定它们是否相关,但smbclient失败似乎并没有触发它们,所以......它们可能不相关。

[1] https://bugzilla.samba.org/show_bug.cgi?id=14901(我尝试了那里的username map script和local nt token from设置,但它不起作用)

[2] https://lists.fedorahosted.org/archives/list/ [电子邮件受保护] /thread/6CTEYZ63WEPHR6GESDSUGNS57XGNTD2U/#6CTEYZ63WEPHR6GESDSUGNS57XGNTD2U

samba
  • 2 个回答
  • 40 Views
Martin Hope
IMTheNachoMan
Asked: 2023-10-09 03:50:38 +0800 CST

在哪里可以从未运行的系统备份中查看 samba 注册表共享配置

  • 6

我有运行 Samba 的 Linux 安装中的所有文件/文件夹的备份以及一些共享。

此安装使用注册表来配置共享,因此它们不在/etc/samba/smb.conf.

我在哪里可以找到已配置的设置/共享?我无法启动进入该系统,所以这不是一个选择。

samba
  • 1 个回答
  • 43 Views
Martin Hope
Arthur Mitchell
Asked: 2023-07-16 22:50:40 +0800 CST

无法让 Samba smv.conf 卷影副本 snapprefix 识别快照

  • 5

我真的同意这个。我的目标是前面带有可选标签的快照以及未标记的快照在 Windows 中显示为以前的副本,例如文件名,例如:

/mnt/pool1/.snapshots/Backup/GMT-2023.07.16-12.53.26
/mnt/pool1/.snapshots/Backup/Sometagname_GMT-2023.07.16-12.53.26
/mnt/pool1/.snapshots/Backup/anothertagname23_GMT-2023.07.16-12.53.26

如果我按如下方式设置 smb.conf,Windows 将按预期看到未标记的卷影副本。

shadow:snapdir = /mnt/pool1/.snapshots/Backup
shadow:basedir = /mnt/pool1/Backup  
shadow:sort = desc
shadow:format = GMT-%Y.%m.%d-%H.%M.%S
shadow:localtime = yes

我已经尝试了我能想象到的正则表达式和设置的每种组合,但我找不到达到此目的的shadow:snapprefix和shadow:delimiter的值。例如,以下是我尝试过的一些组合:

shadow:format = %Y.%m.%d-%H.%M.%S
shadow:localtime = yes
shadow:snapprefix = ^[A-Za-z0-9]\{0,\}\(_\)\{0,1\}\(GM\)\{1\}
shadow:delimiter = T-
shadow:format = %Y.%m.%d-%H.%M.%S

shadow:format = GMT-%Y.%m.%d-%H.%M.%S
shadow:localtime = yes
shadow:snapprefix = ^[A-Za-z0-9]*\(_\)?
shadow:delimiter = GMT-
shadow:format = GMT-%Y.%m.%d-%H.%M.%S

任何帮助将非常感激,因为我已经花了几个小时来研究组合和在线搜索!

samba
  • 1 个回答
  • 21 Views
Martin Hope
Arthur Mitchell
Asked: 2023-07-14 19:55:31 +0800 CST

Samba Shadow_copy2 和快照不会出现在 Windows 中

  • 5

我正在使用 Samba 设置 Ubuntu 服务器。文件系统是 BTRFS,我似乎无法让 Windows 从快照中查看以前的版本。

我的 smb.conf 有这个共享:

[Backup]
    path = /mnt/pool1/backup
    comment = Share for backups
    writeable = yes
    delete readonly = yes
    browseable = yes

    vfs object = recycle shadow_copy2

    recycle:repository = /mnt/pool1/backup/.recycle/%U
    recycle:touch = Yes
    recycle:keeptree = Yes
    recycle:versions = Yes
    recycle:noversions = *.tmp,*.temp,*.o,*.obj,*.TMP,*.TEMP
    recycle:exclude = *.tmp,*.temp,*.o,*.obj,*.TMP,*.TEMP
    recycle:excludedir = /.recycle,/tmp,/temp,/TMP,/TEMP

    shadow:snapdir = /mnt/pool1/snapshots/backup
    shadow:basedir = /mnt/pool1/backup
    shadow:sort = desc
    shadow:format = GMT-%Y.%m.%d-%H.%M.%S

目录结构如下:BTRFS卷挂载在/mnt/pool1,共享和快照目录位于该级别:

ll /mnt/pool1
total 20
drwxr-xr-x 1 root root    98 Jul 14 09:14 ./
drwxr-xr-x 4 root root  4096 Jul 14 09:13 ../
drwxrwxr-x 1 root users   74 Jul 14 11:28 backup/
drwxrwxr-x 1 root users    0 Jul 13 16:50 docker/
drwxrwxr-x 1 root users    0 Jul 13 16:49 homes/
drwxrwxr-x 1 root users    0 Jul 13 16:51 install/
drwxrwxr-x 1 root users    0 Jul 13 16:51 media/
drwxrwxr-x 1 root users   80 Jul 13 16:58 snapshots/
drwxrwxr-x 1 root users    0 Jul 13 16:51 timemachine/

ll /mnt/pool1/snapshots
total 16
drwxrwxr-x 1 root users  80 Jul 13 16:58 ./
drwxr-xr-x 1 root root   98 Jul 14 09:14 ../
drwxrwxr-x 1 root users 184 Jul 14 11:55 backup/
drwxrwxr-x 1 root users   0 Jul 13 16:58 docker/
drwxrwxr-x 1 root users   0 Jul 13 16:58 homes/
drwxrwxr-x 1 root users   0 Jul 13 16:58 install/
drwxrwxr-x 1 root users   0 Jul 13 16:58 media/
drwxrwxr-x 1 root users   0 Jul 13 16:58 timemachine/

使用的结构是快照目录每个共享都有一个子目录。您可以在我已有的快照上看到文件名:

tree -a
.
├── backup
│   ├── .recycle
│   │   └── ubuntu
│   │       └── File from windows - Copy.txt
│   ├── File from windows.txt
│   └── test.txt
├── docker
├── homes
├── install
├── media
├── snapshots
│   ├── backup
│   │   ├── GMT-2023.07.14-09.19.31
│   │   │   └── test.txt
│   │   ├── GMT-2023.07.14-09.30.57
│   │   │   └── test.txt
│   │   ├── GMT-2023.07.14-09.57.41
│   │   │   └── test.txt
│   │   └── GMT-2023.07.14-10.48.31
│   │       └── test.txt
│   ├── docker
│   ├── homes
│   ├── install
│   ├── media
│   └── timemachine
└── timemachine

我在日志中找不到任何内容可以帮助调查此问题,并且似乎没有任何方法可以从服务器端诊断问题所在。谁能建议这里可能出了什么问题或者我如何获得更多诊断信息?非常感谢,亚瑟

samba
  • 1 个回答
  • 19 Views
Martin Hope
Peter
Asked: 2023-03-07 00:28:35 +0800 CST

从 Windows 连接到 debian Samba 共享

  • 6

我有一个带有几个 ZFS 共享的 proxmox 安装。共享是使用创建的

zfs create storage/photos
sudo zfs set acltype=posixacl storage/photos

用户是使用创建的

sudo adduser --system --no-create-home samba-peter
sudo smbpasswd -a samba-peter
sudo setfacl -R -m "u:samba-peter:rwx" /storage/photos

然后我添加

[photos]
   comment = photos
   path = /storage/photos
   read only = no
   writable = yes
   browseable = yes
   guest ok = no
   valid users = @samba-peter

和/etc/samba/smb.conf增加日志记录使用log level = 2 winbind:5。

现在,当我尝试使用Windows 10 21H2 19044.2604它连接时记录

==> /var/log/samba/log.smbd <==
[2023/03/06 17:22:10.679844,  2] ../../source3/lib/tallocmsg.c:84(register_msg_pool_usage)
  Registered MSG_REQ_POOL_USAGE

==> /var/log/samba/log.192.168.0.19 <==
[2023/03/06 17:22:10.685627,  2] ../../source3/auth/auth.c:323(auth_check_ntlm_password)
  check_ntlm_password:  authentication for user [samba-peter] -> [samba-peter] -> [samba-peter] succeeded
[2023/03/06 17:22:10.686016,  2] ../../source3/param/loadparm.c:2864(lp_do_section)
  Processing section "[photos]"

==> /var/log/samba/log.fryr <==
[2023/03/06 17:22:10.689318,  1] ../../source3/smbd/service.c:362(create_connection_session_info)
  create_connection_session_info: user 'samba-peter' (from session setup) not permitted to access this share (photos)
[2023/03/06 17:22:10.689346,  1] ../../source3/smbd/service.c:543(make_connection_snum)
  create_connection_session_info failed: NT_STATUS_ACCESS_DENIED

似乎身份验证成功了(如果我使用错误的密码登录,日志会指出密码不正确)。但是访问目录失败了,但是我错过了什么我给了它访问权限setfacl -R -m "u:samba-peter:rwx" /storage/photos

Samba 版本:4.13.13-Debian
操作系统:Debian GNU/Linux 11 (bullseye)
内核:Linux 5.15.85-1-pve ZFS 版本:zfs-2.1.9-pve1, zfs-kmod-2.1.9-pve1

samba
  • 1 个回答
  • 22 Views
Martin Hope
Raul Chiarella
Asked: 2022-04-14 13:33:28 +0800 CST

仅当存在 Samba 挂载时才绑定挂载?(例如:BIND MOUNT 需要 NFS 挂载 \\172.16.xx\files...)

  • 1

我在 fstab 中使用以下内容安装了 SAMBA:

//source/files /mnt/files cifs user,_netdev,cache=none,credentials=/usr/src/access.smb 0 0

然后我有以下 mount --bind 行:

/mnt/files /var/www/html/data none defaults,bind 0 0

但是第二个挂载不起作用。如果我重新启动计算机,则只有第一个挂载有效。我需要手动安装第二个(使用绑定)

请问,有人可以帮我吗?我在 Unix Stack Exchange 上看到了这篇文章,但我不明白:https ://unix.stackexchange.com/questions/216287/how-do-i-set-up-bind-mounts-on-startup-correctly-in -系统世界

提前致谢。

linux nfs mount samba bind
  • 1 个回答
  • 93 Views
Martin Hope
Jacobta47
Asked: 2022-04-02 14:14:54 +0800 CST

删除了 Ubuntu CLI 驱动器

  • 0

我最近在我的服务器上添加了一个驱动器。但是,今天早上我检查了我的电脑,发现驱动器没有显示在 NTFS 上,我注意到所有文件夹和文件都从服务器上的那个挂载点消失了。

注意:我使用的是 Ubuntu CLI 20.04.4 LTS || 所附图像显示系统日志。

须藤猫/var/log/syslog | grep sdb1

hard-drive ubuntu command-line-interface samba ntfs
  • 1 个回答
  • 16 Views
Martin Hope
nonsensei
Asked: 2022-02-20 14:15:33 +0800 CST

在 LDAP 中停用用户对 SAMBA 文件服务器的访问,同时保持对其他服务的访问

  • 0

我试图切断 ldap 用户对 samba 服务器的访问。禁用密码不是一个选项,因为用户需要保持对连接到同一 ldap 目录的 Nextcloud 等其他服务的访问。我将如何实现这一目标?

这是这个用户的 ldap 目录的样子:

ldap sirectory - 屏幕截图

linux samba ldap
  • 1 个回答
  • 30 Views
Martin Hope
gen_Eric
Asked: 2022-01-14 09:22:01 +0800 CST

允许 samba 共享访问挂载的远程文件存储

  • 0

我在同一个网络上有两台服务器。一个运行 Windows Server 2016,另一个运行 CentOS 8。Windows 服务器是我的主要文件存储,它是我所有数据的所在。CentOS 服务器安装了 Windows 共享并且可以访问其文件。

在 CentOS 上,我设置了一个 samba 共享。为什么?因为我有一个 webapp 在同一台服务器上运行,我希望 webapp 控制谁可以访问什么文件。因此,与其让我们的(内部)用户直接安装 Windows 共享,他们将安装 CentOS 共享,这将是对文件的“看门人”访问。

在 samba 文件夹中,每个用户都有一个文件夹和一个配置,以允许用户仅访问他们的文件夹。webapp 被配置为将符号链接添加到链接到“真实”文件的这些文件夹中。

这就是问题所在。如果我将“普通”文件添加到用户的文件夹中,他们就可以正常访问它。但是,如果我添加一个符号链接(到已安装的 Windows 共享中的文件),它就不会出现在他们面前。我很确定这是一个 SELinux 问题。

这是设置的方式。

  • Windows 共享已挂载

    sudo mount -t cifs //WindowsShare/data /media/WinShare \ 
      -o ip=192.168.1.5,username=user,gid=sambashare
    
    ls -alhZ /media/WinShare
    drwxr-xr-x. 2 root sambashare system_u:object_r:cifs_t:s0  0 Jan 10 16:57 files
    
  • 创建并使用一个 samba 共享/srv/smb(所有 samba 用户都在sambashare组中)

    ls -alhZ /srv
    drwxrwx---.  2 root sambashare unconfined_u:object_r:samba_share_t:s0    6 Jan 13 11:20 smb
    
  • 具有以下/etc/samba/smb.conf内容:

    [global]
        allow insecure wide links = yes
        unix extensions = no
    
    [adminShare]
        path = /srv/smb
        wide links = yes
        follow symlinks = yes
    
  • 作为测试,我添加了一个符号链接和一个文件

    ln -s /media/WinShare/files/test.pdf /srv/smb/test.pdf
    touch /srv/smb/file.bin
    

然后我尝试安装\\CentOS\adminShare在 Windows VM 中,但我没有看到该test.pdf文件,但我看到了file.bin.

如何让 CentOS samba 共享访问已安装的 Windows Server 数据?在设置 CentOS 服务器时,我运行:

sudo semanage fcontext -a -t samba_share_t "/srv/smb(/.*)?"

这是让我看到file.bin的,但我还是看不到file.pdf。我找到了这个,但我不知道是否要更改所有内容:

sudo setsebool -P samba_export_all_rw=1

如何允许 samba 访问该/media/WinShare文件夹?这行得通吗?

sudo semanage fcontext -a -t samba_share_t "/media/WinShare(/.*)?"
centos samba centos8 selinux
  • 1 个回答
  • 207 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve