开发者

How to enable User Account SMB sharing from terminal on Mac OS X?

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.

How to enable User Account SMB sharing from terminal on Mac OS X?


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 开发者_如何学GoSamba 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.


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!


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!


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜