Making public key SSH connections in Cygwin

Here’s a trick I had to relearn to get SSH to make a key-authenticated connection in a Cygwin environment. I have my Windows user directory (c:\Users\lonnon) set as my home directory via the HOME environment variable, but many Cygwin programs, like SSH, look for the home directory within Cygwin’s own bizarre little directory structure, at c:\cygwin\home\lonnon (/home/lonnon in Cygwin’s file space). Because my .ssh directory, which contains my key files, isn’t located where Cygwin wants it, I get a “Permission denied (publickey)” error when attempting to connect.

The solution was so simple, I forgot that I’d already done it on my older laptop. I removed the home directory provided by Cygwin and replaced it with a symbolic link to my “real” home directory.

  > cd /home
  > rm -rf lonnon
  > ln -s /cygdrive/c/Users/lonnon lonnon

Yay, presto, it works. Both ssh and scp can find my keys now.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*