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.
What I already have:
What I've already tried:
What I don't need:
On your Mac, choose Apple menu > System Preferences, then click Sharing . Select the File Sharing tickbox, then click Options. Select “Share files and folders using SMB”.
Set up file sharing on the MacClick Options. Select “Share files and folders using SMB”. In the Windows File Sharing list, select the tickbox next to the user account that will be used to share files with Windows users, enter the password for that user, then click OK. Click Done, then click Done.
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:
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With