su: warning: cannot change directory to /ldapuser/home/user2: No such file or directory

Latest response

Hi I tried configuring autofs in both RHEL 7 & 7.2 on the client for ldap user with NFS home directory, but unable to mount the home dir neither with ssh / su

Please suggest

[root@ldapclient~]# su - user2
su: warning: cannot change directory to /ldapuser/home/user2: No such file or directory
mkdir: cannot create directory '/ldapuser': Permission denied
-bash-4.2$

-bash-4.2$ id
uid=3002(user2) gid=3002(user2) groups=3002(user2) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

-bash-4.2$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.0 (Maipo)

[root@ldapclient~]# getent passwd user2
user2:*:3002:3002:user2:/ldapuser/home/user2:/bin/bash

[root@ldapclient~]# cat /etc/auto.master.d/home.autofs
/home /etc/auto.home

[root@r7nyknode ~]# cat /etc/auto.home
* -fstype=nfs,rw,sync ldapnfsserver.example.net:/ldapuser/home/&

=============================
LDAP + NFS Server
[root@server1~]# exportfs -v
/ldapuser/home 192.168.7.0/24(rw,wdelay,root_squash,no_subtree_check,sec=sys,rw,secure,root_squash,no_all_squash)

Responses

Anthony,

Can you confirm you can manually mount /ldapuser/home/user2? ie. that the NFS server is correctly configured and server1 has access to mount?

Is autofs service running? and have you restarted it since your configuration changes?

Hi Thank you for the reply,

I had managed to fixed it, not with local auto.master & auto.home file in the client machine but by creating automount map in the ldap server, to answer your question yes my NFS is configured correctly and I was able to mount the home dir manually on the NFS client machine as well.

however if I reboot the client machine the autofs seem to show this error : but restarting the autofs on the client after the system boots seem to fix the error manually.

LDAP-NFS Server : r7stmbcp LDAP-NFS Client : r7nyknode

[root@r7nyknode ~]# who -b system boot 2016-07-18 04:06

[root@r7nyknode ~]# systemctl status autofs autofs.service - Automounts filesystems on demand Loaded: loaded (/usr/lib/systemd/system/autofs.service; enabled) Active: active (running) since Mon 2016-07-18 04:07:08 EDT; 40s ago Process: 1518 ExecStart=/usr/sbin/automount $OPTIONS --pid-file /run/autofs.pid (code=exited, status=0/SUCCESS) Main PID: 1757 (automount) CGroup: /system.slice/autofs.service └─1757 /usr/sbin/automount --pid-file /run/autofs.pid

Jul 18 04:07:08 r7nyknode.ajrhel7.net automount[1757]: bind_ldap_simple: lookup(ldap): Unable to bind to the LDAP server: (default), error Can't contact LDAP server Jul 18 04:07:08 r7nyknode.ajrhel7.net systemd[1]: Started Automounts filesystems on demand. [root@r7nyknode ~]#

[root@r7nyknode ~]# systemctl restart autofs [root@r7nyknode ~]# [root@r7nyknode ~]# systemctl status autofs autofs.service - Automounts filesystems on demand Loaded: loaded (/usr/lib/systemd/system/autofs.service; enabled) Active: active (running) since Mon 2016-07-18 04:14:27 EDT; 10s ago Process: 2665 ExecStart=/usr/sbin/automount $OPTIONS --pid-file /run/autofs.pid (code=exited, status=0/SUCCESS) Main PID: 2667 (automount) CGroup: /system.slice/autofs.service └─2667 /usr/sbin/automount --pid-file /run/autofs.pid

Jul 18 04:14:27 r7nyknode.ajrhel7.net systemd[1]: Starting Automounts filesystems on demand... Jul 18 04:14:27 r7nyknode.ajrhel7.net systemd[1]: Started Automounts filesystems on demand. [root@r7nyknode ~]#

[root@r7stmbcp ~]# sestatus SELinux status: enabled [root@r7nyknode ~]# sestatus SELinux status: enabled

[root@r7nyknode ~]# grep user2 /etc/passwd [root@r7nyknode ~]#

[root@r7nyknode ~]# su - user2 Last login: Sun Jul 17 11:45:08 EDT 2016 on pts/1 -bash-4.2$ id uid=3002(user2) gid=3002(user2) groups=3002(user2) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 -bash-4.2$ pwd /home/user2 -bash-4.2$ df -h . Filesystem Size Used Avail Use% Mounted on r7stmbcp.ajrhel7.net:/home/user2 8.5G 4.2G 4.4G 49% /home/user2 -bash-4.2$

So my initial issue is fixed and my current issue is how do I fix this error permanently : Jul 18 04:07:08 r7nyknode.ajrhel7.net automount[1757]: bind_ldap_simple: lookup(ldap): Unable to bind to the LDAP server: (default), error Can't contact LDAP server

Thank you for your guidance.

For me, I had the below output while logging into a server using ldap user. su: warning: cannot change directory to /home/ldap_uder: No such file or directory

I did add below entry to /etc/pam.d/system-auth session optional /lib/security/$ISA/pam_mkhomedir.so

And it worked. Hope it helps for someone who is having similar issue. Thanks!

Regards, Amit Saha

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.