15
$ ssh usaname@login.somehost.no

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)

5 Answers5

9

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.

6

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.

3

In /etc/nsswitch.conf:

db_home:  windows

See The db_home setting. This tells Cygwin to just use the Windows %USERPROFILE% directory as the Cygwin $HOME.

This is necessary if, for example, you want to share the same SSH keys between git (GitHub Enterprise) and SSH to various local Unix/Linux systems.

Setting %HOME% at the OS level did not work (even though $HOME in bash correctly reflects the setting).

You can see from the original question that SSH is trying to update the Windows home directory, which in Vidar's older version of Windows is C:\Documents and Settings\vidar kongsli. In current versions (7+, I think), the equivalent is C:\Users\%USERNAME% (or, if Windows is not installed on C:, %SystemDrive%\Users\%USERNAME%).

1

Set db_home in /etc/nsswitch.conf to the path to your home. This is the method recommended by MSYS2.

Adding a HOME environment variable also works.

Git-for-Windows includes env in db_home, which should read your HOME bash variable, however, it is unreliable.

0

Is the variable HOME exported? Try: export HOME then ssh again.

Greg Hewgill
  • 6,979