ssh uses wrong home directory in Cygwin

$ ssh [email protected]

Could not create directory'/cygdrive/c/Documents and Settings/vidar kongsli/.ssh'.
The authenticity of host 'login.somehost.no (...)' can't be established.
RSA key fingerprint is ....
Are you sure you want to continue connecting (yes/no)? no
Host key verification failed.

$ set | grep HOME

HOME=/cygdrive/d/home/vidar
HOMEDRIVE=C:
HOMEPATH=/cygdrive/d/home/vidar

$ ls ~/.ssh

id_rsa  id_rsa.pub

Any idea why ssh does not use the $HOME environment variable when it tries to locate ~/.ssh?

(edit: fixed formatting)


Have a look at /etc/passwd. Make sure the entry there matches your expected home directory. It's the second to last field for your user's entry.


If your $HOME variable is set, but ssh isn't recognizing it, put this line in /etc/nsswitch.conf:

db_home: /%H

That will set the Cygwin home directory without requiring an /etc/passwd file to exist.