Using the [homes] Share in Samba

Write tutorials here
There are more tutorials here http://community.linuxmint.com/tutorial/welcome
Forum rules
Please don't add support questions to tutorials,start your own thread in the appropriate sub-forum instead. Before you post please read this
Post Reply
altair4
Level 19
Level 19
Posts: 9679
Joined: Tue Feb 03, 2009 10:27 am

Using the [homes] Share in Samba

Post by altair4 » Wed Jul 13, 2011 2:05 pm

Using the [homes] Share in Samba

There are two methods of Creating a Samba share:
Though Nautilus: http://forums.linuxmint.com/viewtopic.php?f=42&t=23169
The Classic Share - by using smb.conf

This HowTo is about a special share that can be set up using the Classic method.

[1] The Normal [homes] Share

The [homes] share allows clients to access their home directories set up on the Samba server by creating a share "on the fly" at the moment the client asks for it instead of creating a home share outright for each user. The normal way this is done is by adding a single share definition to /etc/samba/smb.conf that looks like this:

Code: Select all

[homes]
comment = Home Directories
valid users = %S
read only = No
create mask = 0700
directory mask = 0700
browseable = No
Note: This is already set up for you in smb.conf if you are running any of the Debian based Mint distros but you will have to set "read only" to No.

It is different from a normal classic share:

* %S is used to represent the name of the remote user.
* %S is replaced by the remote user's name automatically the moment he tries to access his share.
* There is no path - By default it will point to /home/%S.
* It is not browseable - The client cannot browse to the share but must ask for it by name.
* It is not accessible to any other user.

On a Linux client
You cannot browse to the share but must ask for it using a syntax that's different from a normal share:
Instead of "smb://server/share" you access it by:

Code: Select all

smb://server/user-name
As soon as you do that and the server authenticates that user-name, a share is created at that moment to /home/user-name.

On a Windows client
Something close to magic happens on the Windows side of things because of the way Windows automatically sends the client user's actual local Windows login user-name and password when it browses the network. If the Linux Samba server has a user and a samba password that matches exactly the Windows user's name and login password then the remote user will see and have access to his share automatically. All other Windows or Linux users will not see this particular share when they browse. You can of course set the password to be something else so that this doesn't happen but then you will be prompted for a password at the machine name level before you can view the shared folders.

So to make this work:

* Set up the [homes] share definition in /etc/samba/smb.conf as indicated above.
* Create a new user that represents the remote client though Menu > Administration > Users and Groups.
* Create a samba password for that user:

Code: Select all

sudo smbpasswd -a user-name
* Restart samba:

Code: Select all

sudo service smbd restart
If you are using Debian based Mint's:

Code: Select all

sudo service samba restart
[2] A different way to define a [homes] share.

There is a problem with the method described above. The remote user has to have a login account on the server so that his home directory is created. But you don't actually have to have [homes] point to the home directory on the server. You can point it anywhere. You do that by adding a path to the share definition.

Create a different directory for the remote clients:

Code: Select all

sudo mkdir /home/samba
Add a path to the share definition in option [1]:

Code: Select all

[homes]
comment = Home Directories
path = /home/samba/%S
valid users = %S
read only = No
create mask = 0700
directory mask = 0700
browseable = No
Now you can create a user on the server that does not have a local login user-name or a home directory and then add a samba password for that user:

Code: Select all

sudo useradd -s /bin/true user-name
sudo smbpasswd -a user-name
Then create a subfolder for that client user with the exact user-name of the remote client and change it's permissions:

Code: Select all

sudo mkdir /home/samba/user-name
sudo chown user-name:user-name /home/samba/user-name
sudo chmod 775 /home/samba/user-name
Then restart samba.

It will work and follow the same rules as the method described in [1] but to a different path.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.

Post Reply

Return to “Tutorials”