.bashrc file not created in ldap client machine when using ldap authentication

1.3k Views Asked by At

My objective is to configure a machine as client to use ldap authentication from a ldap server. I added user in ldap server. Also registered ldap service to be used by client.

But the problem is when I am trying to login into the ldap client machine, I am not getting the "user@hostname" prompt, instead I am getting "-bash-4.1$".

I searched and find its something to do with ".bashrc" files such as ".bash_history", ".bash_profile", ".bash_logout".

I can manually create these files but I want them to be automatically generated, and executed while login.

If anyone knows the cause of the problem and the solution please share.

Thanks, Yogesh

2

There are 2 best solutions below

0
On

I had this problem too and I solved deleting the "/home/< ldapuser >" and then I login again and the home directory was created. Also you can check if /etc/pam.d/system-auth has properly pam_oddjob_mkhomedir.so

session optional pam_oddjob_mkhomedir.so umask=0077

To enable mkhomedir you can run authconfig --enablemkhomedir --update

0
On

You should create a script in /etc/profile.d for this propose, like that:

cat /etc/profile.d/bash_create.sh
a='export PS1="\[$(tput bold)\]\[$(tput setaf 2)\][\u@\h \W]\\$ \[$(tput sgr0)\]"'
b='export other variable'
c='export other variable'
d='alias ...."
 if [ ! -f BASHRC ]; then   #if not exists
        echo -e "$a\n$b\n$c\n$d" >> $BASHRC
        source $BASHRC #execute bash script
 fi