How to create users' home directory by using "pam_mkhomedir.so" module if it does not exist in autofs ?

Solution In Progress - Updated -

Issue

  • How to create users' home directory automaticlly if it does not exist by using autofs ?

Environment

  • Red Hat Enterprise Linux 6

    Assume that there are 3 machines: machineA as NFS server,machineB as autofs server and machineC.

  • Create and share a directory in machineA(NFS server).

        # vim /etc/exports
        /export/home   *(rw,sync,no_root_squash)
    
  • Configure autofs in machineB.

    1. Configure auto.master.

      # vim /etc/auto.master
      /mnt/home   /etc/auto.home
      
    2. Configure auto.home.

      # vim /etc/auto.home
      home            /             -rw   192.168.122.10:/export/home 
      or
      home            /nic          -rw   192.168.122.10:/export/home/nic
      
    3. Configure password-auth.

      # vim /etc/pam.d/password-auth 
      (Change the line that has the keyword "optional" like below)
      session     optional      pam_mkhomedir.so debug
      
    4. Configure system-auth.

      # cat /etc/pam.d/system-auth |grep optional
      (Change the line that has the keyword "optional" like below)
      session     optional      pam_mkhomedir.so debug
      
    5. Edit /etc/sysconfig/autofs and set:

      OPTIONS="--debug"
      
  • Test.

    1. Create a user test in machineB.

      # useradd test 
      
    2. Delete user test home directory.

      # rm -rf /home/test
      
    3. SSH to machineB from machineC.

      # ssh test@<machineB-IP>
      
    4. If it comes out and show like this:

      $ ssh test@<machineB-IP>
      test@<machineB-IP>'s password: 
      Creating directory '/home/test'
      Last login: <time> from <IP-address>
      NFS autofs/home builder
      

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content