Configure Users Home Directory OpenLDAP Server to CentOS 7 Client Machine

Configure "Mount" Users Home Directory from OpenLDAP Server to CentOS 7 Client Machine/Red Hat 7 Client Machine

To access personal home folders and files from OpenLDAP Server to CentOS Linux 7 client machines use Network File Sharing (NFS) Server. NFS server use to access file and folders from Linux to Linux machine. Use NFS with AutoFS feature package to auto mount the users home directory form OpenLDAP Server to CentOS Linux 7 client machines.

Server Side Configuration "OpenLDAP Server"

To mount Home Directory of OpenLDAP users from OpenLDAP Server to CentOS Linux 7 client machine use "exports" file that available in "/etc/exports" directory.

Edit the "exports" file by use of vi editor.

vi /etc/exports

installation and configuration of nfs server on centos 7

Edit the below line in "exports" file.

/home/ *(rw,sync)

installation and configuration of nfs server on centos 7

To Install NFS Server packages "rpcbind and nfs-utils" on OpenLDAP Server type the below command.

yum -y install rpcbind nfs-utils

installation and configuration of nfs server on centos 7

NFS server packages has successfully installed.

installation and configuration of nfs server on centos 7

After install the NFS Server packages start and enable the rpcbind and nfs services. To start and enable the rpcbind and nfs services on OpenLDAP Server type the below commands.

systemctl start rpcbind
systemctl start nfs
systemctl enable rpcbind
systemctl enable nfs

how install and configure nfs server on centos 7

Type the below commands to check home directory has configured for mount from OpenLDAP Server to CentOS Linux 7 client machine.

showmount -e localhost
showmount -e

how install and configure nfs server on centos 7

Allow Firewall "Firewalld" rules on OpenLDAP Server for connect CentOS Linux 7 client machine "Linux2" to OpenLDAP Server.

firewall-cmd --permanent --add-port=111/tcp
firewall-cmd --permanent --add-port=2049/tcp
firewall-cmd --permanent --add-port=20048/tcp
firewall-cmd --permanent --add-port=111/udp
firewall-cmd --permanent --add-port=2049/udp
firewall-cmd --permanent --add-port=20048/udp
firewall-cmd --reload

firewall rules connect centos client machine to openldap server for nfs with autofs


Client Side Configuration "Linux2"

To Install NFS client packages "rpcbind and nfs-utils" on CentOS Linux 7 client machine "Linux2" type the below command.

yum -y install rpcbind nfs-utils

configure users home directory from openldap server to centos client machine use nfs

The NFS client packages has successfully installed.

configure users home directory from openldap server to centos client machine use nfs

After install the NFS client packages start and enable the rpcbind and nfs services. To start and enable the rpcbind and nfs services on CentOS Linux 7 client machine "Linux2" type the below commands.

systemctl start rpcbind
systemctl start nfs
systemctl enable rpcbind
systemctl enable nfs

configure users home directory from openldap server to centos client machine use nfs

For auto mount the Home Directory from OpenLDAP Server to CentOS Linux 7 client machine install Autofs package. To install autofs package on CentOS Linux 7 client machine "Linux2" type the below command.

yum install –y autofs

configure users home directory from openldap server to centos client machine use nfs

Autofs package has successfully installed on CentOS Linux 7 client machine "Linux2".

configure users home directory from openldap server to centos client machine use nfs

Configure the autofs file "auto.master" that available in "/etc/auto.master" directory. To configure the "auto.master" file by use of vi editor.

vi /etc/auto.master

how install and configure autofs on centos 7

Edit the below line in "auto.master" file to mount the home directory from OpenLDAP Server to CentOS Linux 7 client machine "Linux2".

/home /etc/home.map

how install and configure autofs on centos 7

In the above image /home is mount point of CentOS Linux 7 client machine "Linux2" and /etc/home.map file is the configuration file to connect OpenLDAP Server with CentOS Linux client machine "Linux2".

To configure the "home.map" file by use of vi editor type the below command.

vi /etc/home.map

how install and configure nfs with autofs on openldap server for centos 7 client machine

Edit the below line in "home.map" file.

* -fstype=auto ldap-dns.pakistan.local:/home/&

how install and configure nfs with autofs on openldap server for centos 7 client machine

To enable and restart autofs service type below commands.

systemctl enable autofs
systemctl restart autofs

how install and configure nfs with autofs on openldap server for centos 7 client machine

To Check the OpenLDAP users home directory is export from OpenLDAP Server to CentOS Linux 7 client machine "Linux2" type the below command.

showmount -e ldap-dns.pakistan.local

how install and configure nfs with autofs on openldap server for centos 7 client machine

To check the home directory of OpenLDAP user "user1" is auto mount, Switch from root user to OpenLDAP user1.

su - user1

configure users home directory from openldap server to centos client machine use nfs

In the above image you can see that home directory of user1 is auto mount from OpenLDAP Server "ldap-dns.pakistan.local" to CentOS Linux 7 client machine "Linux2.pakistan.local". ls command is use to list files and folders in current location. pwd command is use to give the complete path of current directory. Currently user1 is present in its own home directory.

Create file in user1 home directory type the below command

touch pakistan

configure users home directory from openldap server to centos client machine use nfs

In above image ls command is use to check pakistan file has created.

Verify the pakistan file is available in OpenLDAP Server Home Directory 

Enter in the home directory of user1 by use of cd command then type ls command to list the files and folder of user1 home directory.

cd /home/user1
ls

configure users home directory from openldap server to centos client machine use nfs

Thanks for read this Article

Comments