如何在 Mac OS X 上从终端启用用户帐户 SMB 共享?

发布于 2024-12-08 17:40:11 字数 592 浏览 0 评论 0原文

我正在尝试从终端启用帐户共享。我不知道该怎么做。

这将在我当前正在编程的应用程序内部使用。应用程序创建一个隐藏用户,然后应为此用户启用 SMB 共享。稍后,我需要使用 SMB 通过另一台服务器连接到此共享。

我需要相同的效果,就像进入系统偏好设置 → 共享 → 文件共享 → 启用任何帐户使用 SMB 进行共享。

在此处输入图像描述


我已有的:

  • 知道如何创建隐藏用户
  • 我已经 知道如何创建单独的共享文件夹,但不知道帐户共享。

我已经尝试过的:

  • 我已经尝试扫描系统以查找上次修改的文件,以在 Samba 配置文件中查找一些信息,但没有帮助。

我不需要什么:

  • 我无法使用 SSH 执行此操作。这些文件夹需要通过 SMB 共享。

I'm trying to enable Account Sharing from terminal. I can't figure out how to do that.

This will be used from inside an application I'm currently programming. The application creates a hidden user, then should enable SMB sharing for this user. Later, I need to connect to this share via another server using SMB.

I need the same effect as going to System Preferences → Sharing → File Sharing → enable any account for sharing using SMB.

enter image description here


What I already have:

  • I know how to create a hidden user
  • I already know how to create individual shared folders, but not account sharing.

What I've already tried:

  • I already tried to scan the system for last modified files to find some information in Samba config files, but it didn't help.

What I don't need:

  • I can't do this with SSH. The folders need to be shared via SMB.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

謌踐踏愛綪 2024-12-15 17:40:11

这适用于 OS X 10.5、10.6、10.7

首先在终端中输入

pwpolicy -u SomeUser -sethashtypes SMB-NT on

SomeUser 也可以隐藏,没关系。这与启用该复选框具有相同的效果,如上图所示。

之后:

dscl . -passwd /Users/SomeUser "UserPassword"

当它要求输入密码时,这会产生与从系统偏好设置中启用它相同的效果。这和填写密码是一样的。

如果您想在该帐户上禁用 SMB(SomeUser 可以再次隐藏):

pwpolicy -u SomeUser -sethashtypes SMB-NT off

PS 在 Mac OS X Lion 中,他们更改了 SMB (SMBX) 的实现。但请注意,它仍然使用相同的共享点机制来创建共享,并且由目录服务负责。此外,它仍然以相同的方式在帐户上启用 SMB!

THIS WORKS FOR OS X 10.5, 10.6, 10.7

First type this in terminal

pwpolicy -u SomeUser -sethashtypes SMB-NT on

SomeUser can also be hidden, it doesn't matter. This gives the same effect like enabling that checkbox as shown in the picture above.

After that:

dscl . -passwd /Users/SomeUser "UserPassword"

This gives the same effect, as enabling it from System Preferences, when it asks for a password. It's the same like filling in that password.

If you want to disable SMB on that account (SomeUser can be hidden again):

pwpolicy -u SomeUser -sethashtypes SMB-NT off

P.S. In Mac OS X Lion, they changed their implementation for SMB (SMBX). But be aware that it still uses the same Share Points mechanism for creating a share, and Directory Service is responsible for it. Also it still works the same way for enabling SMB on account!

奈何桥上唱咆哮 2024-12-15 17:40:11

我已经在 10.7 中尝试了上面的答案,我很高兴看到在 SMB-NT 打开后,该设置有效地出现在“共享选项”屏幕中。

问题是,由于该用户启用了该方法,我无法从 Windows 进行连接。所以我不得不尝试我之前找到的另一个深奥的解决方案,但我不想尝试:

  • 是关于更改 /var/db/dslocal/nodes/Default/users/.plist 文件重新排序authentication_authority数组值。

这是完整的解释:
https://discussions.apple.com/thread/3211072?start=0& ;tstart=0

进行更改后,用户 smb 设置再次关闭(可能是因为我使用了 .plist 旧文件),但我能够有效地将其打开并从 Windows 连接!

I've tried the answer above in 10.7 and I was happy to see that after the SMB-NT on, the setting appeared effectively on in the Sharing Options screen.

The problem is that being that user enabled with that method I could not connect from Windows. So I had to try another esoteric solution that I had found before and I didn't want to try:

  • Is about changing the /var/db/dslocal/nodes/Default/users/.plist file reordering the authentication_authority array values.

Here is the full explanation:
https://discussions.apple.com/thread/3211072?start=0&tstart=0

After making that change, the user smb setting was again OFF (maybe because I used a .plist old file), but I was able to effectively turn it ON and to connect from Windows!

本王不退位尔等都是臣 2024-12-15 17:40:11

sudo launchctl加载-w
/System/Library/LaunchDaemons/com.apple.smbd.plist

sudo 默认写入
/Library/Preferences/SystemConfiguration/com.apple.smb.server.plist
EnabledServices - 阵列磁盘

这可能是另一种方式。

要再次禁用它, - 卸载它。

sudo launchctl卸载-w
/System/Library/LaunchDaemons/com.apple.smbd.plist

sudo launchctl load -w
/System/Library/LaunchDaemons/com.apple.smbd.plist

sudo defaults write
/Library/Preferences/SystemConfiguration/com.apple.smb.server.plist
EnabledServices -array disk

This could be one other way.

And to disable it again, - unload it.

sudo launchctl unload -w
/System/Library/LaunchDaemons/com.apple.smbd.plist

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文