2

I've been trying to make ssh connection using Cygwin, but it doesn't recognize my id_rsa public key file.

My command lines are as follows:

$ssh XXX@XXX -i /home/XXX/.ssh/id_rsa
Warning: Identity file /home/XXX/.ssh/id_rsa not accessible: No such file or directory.
Permission denied (publickey,XXX).

(Sorry, I used XXX for the private information.)

I copied my .pub file to C:\cygwin\home\XXX.ssh folder. But it still spits out the same error message.

Thank you so much in advance.

AlG
  • 14,697
  • 4
  • 41
  • 54

3 Answers3

2

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.

hello
  • 920
  • 1
  • 7
  • 14
  • 1
    I just ran into this problem today. After some investigation I realized my issue (and maybe yours) was that I didn't install openssh in Cygwin, so running `which ssh` in Cygwin output `/cygdrive/c/Windows/System32/OpenSSH/ssh` instead of `/usr/bin/ssh`. After installing openssh in Cygwin everything started working. – Rick Oct 27 '22 at 21:09
1

From your post it looks like SSH is looking for /home/XXX/.ssh/id_rsa and is not finding it. Ensure that the .pub file you copied is named correctly and has the right permissions.

AlG
  • 14,697
  • 4
  • 41
  • 54
  • 1
    Hi. Thank you for your input. But I do have "full control" for the permission of this .pub file. It's not in incorrect file name either. – Natsuha Kuroda Jan 30 '13 at 19:21
  • It's actually looking for a file with the specific name `id_rsa`, not id_rsa.pub or anything else ending in ".pub". And the file should be the _private_ key file. the .pub file is the _public_ key file, which is not what it's looking for. – Kenster Feb 27 '15 at 18:53
1

Try putting the option before the hostname...