Background
Most cygwin executables, map Unix path /home/XXX/.ssh/id_rsa
to Windows path C:\cygwin64\home\XXX\.ssh\id_rsa
. Except that ssh.exe maps the same Unix path to Windows path C:\home\XXX\.ssh\id_rsa
.
That is if you do cat ~/.ssh/id_rsa
, it will print out the contents of C:\cygwin64\home\XXX\.ssh\id_rsa
, but if you do ssh XXX@XXX -i /home/XXX/.ssh/id_rsa
it will try to read the key from C:\home\XXX\.ssh\id_rsa
.
I assume this is bug in Cygwin. In any event, this is a workaround that worked for me (on Windows 10 and the latest version of Cygwin as of October 2020).
Solution
Open Administrator command prompt. Go to C:\
and issue the command mklink /D home c:\cygwin64\home
That's it.
But for me tat least, once I solved the above problem, I started getting the problem described in this Superuser question https://superuser.com/questions/1296024/windows-ssh-permissions-for-private-key-are-too-open. I used the solution from the most upvoted answer and ssh finally worked for me.