Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a Debian box authenticating against our Active Directory and it's working well. Currently, only users who've logged into the server via SSH (against AD) have an directory they can access through SMB. The directory is created when the user logs via SSH. Is it possible for a user to login via SMB and the directory auto-creates?

Here's my common-session file from my pam.d directory:

session    required skel=/etc/skel/ umask=0066
session    sufficient
session required
share|improve this question

2 Answers 2

up vote 4 down vote accepted

It is possible. To do it you need to add a line to your share config in Samba, and create a script.

    path = /srv/homes
    comment = User home-directories
    root preexec = /usr/local/sbin/mksmbhome

The 'mksmbhome' file is a shell-script that will run every time a user connects to that share. It should test for the existence of a home-directory, and if not present, create one with any required directories and files.

Doc: section

share|improve this answer
Thank you. For the record, this is what I used: root preexec = mkdir %H && chown %U:%G %H – jeffkolez Oct 21 '10 at 17:16

Alternative to sysadmin1138 solution, is to add to your smb.conf following setting:

obey pam restrictions = yes

If your users can already login using SSH, that's the only thing you need to do. Otherwise you need to ensure that the users are visible using getent passwd.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.