How to create users' home directory by using "pam_mkhomedir.so" module if it does not exist in autofs ?
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.
-
Configure
auto.master.# vim /etc/auto.master /mnt/home /etc/auto.home -
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 -
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 -
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 -
Edit
/etc/sysconfig/autofsand set:OPTIONS="--debug"
-
-
Test.
-
Create a user
testin machineB.# useradd test -
Delete user
testhome directory.# rm -rf /home/test -
SSH to machineB from machineC.
# ssh test@<machineB-IP> -
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 of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
