2

I have linked my server with LDAP for ssh login. I get the Following error while logging in using ssh.

Could not chdir to home directory /home/ldap/sharukhk: No such file or directory

shahrukh@shahrukh:~/deploy$ ssh [email protected]
[email protected]'s password: 
Last login: Tue Sep 29 14:28:10 2015 from 10.200.100.245
Could not chdir to home directory /home/ldap/sharukhk: No such file or directory
-bash-4.1$ 

I have tried the following method to auto create home directory while login but it does not work

session required pam_mkhomedir.so skel=/etc/skel/ umask=0077
5
  • Does /home/ldap exist? Sep 29, 2015 at 17:03
  • i have created that directory manually Sep 29, 2015 at 17:05
  • Which distro is this? For Debian/Ubuntu I had to add this line to common-session to get it to work. Sep 29, 2015 at 17:22
  • it is centos os Sep 29, 2015 at 17:27
  • while using pam_mkhomedir works fine, modern systems prefer autodir daemon. If you decide for autodir, you can leave pam untouched. Oct 16, 2015 at 9:47

3 Answers 3

3

This can be enabled using authconfig.

authconfig --enablemkhomedir --update

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Identity_Management_Guide/users.html#homedir-pammod

1

same thing happens on on ubuntu 18.04 the fix is

# pam auth update

then select

[*] Create home directory on login

if you find out how to do this from the CLI please post me a comment

1

IF SELinux is enabled or disabled then Need to config sshd pam module To creating home directory

vi /etc/pam.d/sshd
# pam_selinux.so close should be the first session rule
session required pam_mkhomedir.so skel=/etc/skel/ umask=0022

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .