Friday, March 02, 2007

Solving Pesky ssh Issues in Cygwin

Every time that I re-install cygwin and I use ssh for the first time, I encounter minor annoyances. My biggest annoyance is the fact that no matter how many times I log into a remote machine, cygwins' ssh utility tells me the following:

Could not create directory '/home/ME/.ssh'.
The authenticity of host ' (1xx.82.67.xx)' can't be established.
RSA key fingerprint is 6c:59:15:64:ed:c8:67:35:d6:ed:1c:a2:ee:87:2b:3f.
Are you sure you want to continue connecting (yes/no)?
Once I enter 'yes', I get the following:

Failed to add the host to the list of known hosts (/home/ME/.ssh/known_hosts).

So that message occurs every single time that I attempt to login to the remote machine.

So the question is, how do I solve this problem? The solution was actually quite simple!

First locate the file called 'passwd' in your C:\path\to\cygwin\etc directory and open it with wordpad.

Second, replace the text
/cygdrive/c/Documents and Settings/YOUR_NAME

Finally, save the file.

In hindsight, the solution is very straightforward, but it took me hours to finally figure out. Hopefully, I can save your time!


Anonymous said...

THANK YOU! you saved me a lot of time. I also didn't know where to put my .ssh keys (the problem is related, because they go in the same directory). You solved both my problems at once.

Unknown said...

also (less enlightening but more strait forward), run this command as suggested inside the man page of mkpasswd :

mkpasswd -l -p "$(cygpath -H)" > /etc/passwd

cg said...

just to add my two cents,

Its actually the text "/cygdrive/.." its not the drive where cygwin is installed etc. Just enter it verbatim.

Also be careful with capital letters. Us windows users get lazy about that.

For vista and win7, its /cygdrive/c/users/your_name

fil said...

Alternatively, if you're like me and don't use the /home directory at all, you can make a symlink to it:
ln -s ~ /home
(note that you'll have to delete your /home to do this, and set ~ to be /cygdrive/c/Users)

Anonymous said...

The far easier method that i never see people use is to run the sync from windows in a batch file and set the HOME variable to the folder that i want the ssh file created eg:


Which stick the .ssh folder and .unison folder in the folder at time of script run :)


Unknown said...

Cheers for this - worked perfectly.

Anonymous said...

Thank you so much!! I have spent long hours and finally I got it working thanks to you.

Anonymous said...

Thank you very much. This solution was quick to implement.

Anonymous said...

Joy! actual joy cascaded through me when I found your solution. It's the small things that drive me nuts...

Unknown said...

I overcame the inability to achieve what you (and I) were trying to do by using the -o and -i options, however I was still informed that "Cannot create directory /home/Adam/.ssh". However, doing this COMPLETELY removes the need for those options and the annoying error message. Yay!

Anonymous said...

I just added the Environment variable:
HOME=D:\Documents and settings\[my_user]\

This worked perfectly.