Linux LDAP – Edit Home Directory for LDAP User

ldaplinuxpasswdsssd

I have an LDAP user who accesses a server based on having the appropriate LDAP host attribute via sssd. This user does not show up in /etc/passwd because he is not local. How do I modify his home dir location if he has already logged in and it was created in the default location? RHEL 6 Is it just usermod -d /new/location -m?

Best Answer

This is actually shockingly easy. If your nsswitch is files ldap; just add an entry for them in /etc/passwd and modify whatever parameter you want. If they don't already exist in /etc/passwd, you could do getent passwd <username> | sed 's|/home/<username>|/home/remoteusers/<username>|g' >> /etc/passwd for instance to change their home directory from the root of /home to a subfolder of home called remoteusers. The caveat is that you cannot use useradd or usermod, you must edit the file with an editor.

Related Question