MacOS – Added SSH User, No Home Directory

macosssh

So, on a Yosemite system, I enabled Remote Login (ssh) and added a specific user. When I ssh as this user, my home directory defaults to /var/empty. Was I supposed to do anything else to enable a correct Home directory? (Note that the system has an Active Directory network account server.)

Best Answer

So not sure how you created the user but if you are expecting a locally cached home directory, and this is not a network account, you will want to user commands like the following to create the user account:

Credit for Script: http://wiki.freegeek.org/index.php/Mac_OSX_adduser_script

dscl . -create /Users/$USERNAME
dscl . -create /Users/$USERNAME UserShell /bin/bash
dscl . -create /Users/$USERNAME RealName "$FULLNAME"
dscl . -create /Users/$USERNAME UniqueID "$USERID"
dscl . -create /Users/$USERNAME PrimaryGroupID 20
dscl . -create /Users/$USERNAME NFSHomeDirectory /Users/$USERNAME
dscl . -passwd /Users/$USERNAME $PASSWORD

If you are looking to have the user directory provided by ActiveDirectory then ensure you have the following checked in your Active directory config and that all your server side AD settings are correct for this:

'User UNC Path from Active Directory to derive network home location'