I have Cygwin installed on Windows 7. I made default install. I would like to use ssh config file (~/.ssh/config) to set host and options for connecting.

Normal ssh command is not able to find the config while I try to connect: ssh host If I explicitly specify config file, everything is OK: ssh -F ~/.ssh/config

I cannot found any option to set ssh client, something like /etc/ssh

Maybe ssh doesn't know where is my home folder? (I have set HOME environment variable to my home folder)


Solution 1:

Install the openssh package and then run ssh-host-config. It will generate a "ssh_config" file in /etc/.

Solution 2:

I had the same issue. I wanted to use ~/.ssh/config because I was already using that directory for other applications and didn't want to maintain 2 copies. So creating an /etc/ssh_config directory wasn't the ideal solution.

As Fujimoto Youichi mentions, ssh looks at /etc/passwd for your home directory and not the $HOME environment variable.

The current cygwin versions (I'm using 2.6) no longer creates /etc/passwd as part of the install. However, it is easy to create a new one:

    mkpasswd -c -p "$(cygpath -H)" > /etc/passwd
  • -c Adds the current user to the passwd file
  • -p "$(cygpath -H)" Adds your current home directory

https://cygwin.com/cygwin-ug-net/mkpasswd.html has more details on the available flags.

I haven't looked at the code, but ssh's preference seems to be:

  1. /etc/ssh_config
  2. ~/.ssh/config

So if you only want to use the ssh configuration information from ~/.ssh/config, then be sure to delete /etc/ssh_config.

Also, be sure to open a new cygwin terminal window after making changes, for them to become available.

Solution 3:

ssh command looks for its config file under home directory from /etc/passwd. So setting HOME variable will not work.

There are many ways but we can fix it by simply making a symlink as follows.

ln -s ~ /home