I am trying to start a system (Hadoop, but that should not matter much for this question), and need to be able to ssh to localhost. I do this on windows with cygwin. The cygwin SSHD service is running, and ssh localhost works (as does ssh username@localhost). However, when I do, it says:

Could not chdir to home directory : No such file or directory
mkdir: cannot create directory `': No such file or directory
  could not be created.
Setting HOME to /tmp.

Somehow it tries to chdir to an directory with an empty name, which fails. However, I do not see why it would do that. The /home/username folder exists like it should, and is accessible after logging in over ssh.

Any pointers on where ssh would get the empty folder name from? (some configuration I don't know about maybe?).

Thanks in advance!

  • 1
    Has the user got a home directory set? (you can check via grep user /etc/passwd, or echo $HOME) – qweet Mar 27 '12 at 13:46
  • @qweet: good one, $HOME is set, but the entry in /etc/passwd is empty for the user. Can I just add the path in there? – openbas2 Mar 27 '12 at 14:07
  • Better to use usermod- the command is usermod -d /some/directory/wherever user. – qweet Mar 27 '12 at 14:12
  • @qweet: that indeed solves the problem (I guess it was quite a noob question....). Only problem is that now it suddenly needs a password, but probably I can disable that somewhere.... If you add your answer as a real answer, I will accept it. – openbas2 Mar 27 '12 at 14:14
  • Password? For logging in or for making the change? If its the change then doing prepending a sudo will force it to work, and if it's the latter, it's because you now have a home directory and your settings are no longer in /tmp (you might want to do an ll -lsa to see what hidden files have been created there then move them over to the new directory.) – qweet Mar 27 '12 at 14:21

Does your user have a home directory? You can check by echo $HOME and grep user /etc/passwd, the former echoing the user's directory, and the grep looking to see the home directory stored in the password file.

If it turns out your user doesn't have a Home directory set in passwd, then doing a usermod -d /some/directory user will force the change, and the user will then log in on that directory.

Also note that since your original home was set to /tmp, there may be some user setting files that will need transferring over to the new directory (like .ssh for example).

  • Note: usermod is not available in my installation of cygwin, so I had to restart the cygwin SSHD service to make this change take effect – centic Jul 8 '15 at 8:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.