4

I'm using Win XP and I'm trying to connect by SSH to remote host using RSA key.

I've investigated that cygWin recognizes Documents and Settings dir as home directory

Z:\app\cwRsync\bin>cygpath -H
/cygdrive/c/Documents and Settings

I've created .ssh directory in Documents and Settings/user/.ssh and moved known_hosts, id_rsa, id_rsa.pub there.

Now, I'm trying to connect via ssh.exe to remote host

Z:\app\cwRsync\bin>ssh -p 22 myuser@remotehost.com
Could not create directory '/home/user/.ssh'.
The authenticity of host '[remotehost.com]:22 ([remotehost.com]:22)' can't be established.
RSA key fingerprint is f7:f4:2c:e0:c6:7e:d2:a4:45:70:63:df:bf:f2:84:46.
Are you sure you want to continue connecting (yes/no)?

What I'm doing wrong? Why ssh.exe couldn't create directory /home/user/.ssh?

Thank you.

  • 1
    you have defined the HOME variable with the correct path? or maybe u need to mount /home to the correct directory, have past some time since I used cygwin – Aragorn Apr 25 '12 at 23:21
  • @Kirzilla Accept Kevin M's answer! along with my comment it finally provided a working solution, which was nowhere else to be found. :< – sjas Feb 28 '13 at 15:05
4

Try changing the permissions on .ssh to 700. This is because .ssh is a sensitive directory where private keys are stored.

Another thing to try would be ln -s /cygdrive/c/Documents\ and\ Settings /home, thus causing searches in /home to be redirected to Documents and Settings.

  • The creation of the symbolic link via ln -s ... in /home, with the link being named like your personal user folder does indeed help!!! Afterwards the right folder can be found. After fixing the folder rights (recursively adding root group to .ssh folder.) I was good to go. THANK YOU! Sadly I can just upvote this once... – sjas Feb 28 '13 at 15:03
3

Oh man... The hours I've burned on this, too...

For me, the solution was: Set a Windows User environment variable named HOME that points to the %USERPROFILE%

Apparently (black box view) this allows the cygwin $HOME environment variable to resolve cleanly to the %USERPROFILE% windows variable and everything comes out in the wash. This will preserve all Windows security for the user profile, too, which makes it the best solution I've seen (... and I've seen a few of them lately!)

Suggestion found at: http://hrivera99.blogspot.com.au/2013/09/openssh-failed-to-add-hosts-to-list-of.html

Hope this saves other people a few hours out of their lives!

  • Tried this from both control panel and command line SET HOME=%USERPROFILE% and still got Could not create directory '/home/USER/.ssh'. – Simon East May 29 '17 at 2:55
2

In your Documents and Settings folder of your local machine, create the folder home\<user>. For some reason, cwRsync won't create these folders for you. I didn't change my cygpath, so I created mine in C:\Program Files\cwRsync\home\<user>.

1

I solved the problem on my Win7 laptop by creating a directory junction. Open a command tool with admin privileges and run the command:

mklink /j "C:\Program Files (x86)\cwRsync\home" "c:\Users"

Reason :

ssh expects a /home/user_name/.ssh cygwin directory which is the Windows directory C:\Program Files (x86)\cwRsync\home\user_name.ssh given by

cygpath -w /home/user_name/.ssh

A Windows users expects his home directory under the Users directory: C:\Users\user_name A link from C:\Program Files (x86)\cwRsync\home to C:\Users makes the trick.

Note: This may also work with a symbolic link : mklink /d but i did not test it.

0

It can't create it because it's already been created. I'd suspect a permissions issue. What are the permissions on ~, ~/.ssh and the files within ~/.ssh?

  • I've changed permissions to 777, drwxr-xr-x 1 user mkgroup 0 Mar 30 16:01 Documents and Settings |||||||||| drwxr-xr-x 1 user mkgroup 0 Mar 30 16:01 user |||||||||| There is neither .ssh file in Documents and Settings/user/ nor in Documents and Settings/ – Kirzilla Mar 30 '10 at 12:05
  • Is there any ways to tell ssh.exe to look for keys not in .ssh directory, but in another one? – Kirzilla Mar 30 '10 at 12:17
  • In your question, you said that you created a .ssh directory, but in your comment you say it's not there. Also, to be clear, in your question you say "I've created .ssh directory in Documents and Settings/user/.ssh". Does that mean a directory ".ssh" within another directory ".ssh"? If so, the files need to be in /cygdrive/c/Documents and Settings/.ssh not in a directory below that. There shouldn't be any file called ".ssh" only a directory with that name. – Dennis Williamson Mar 30 '10 at 13:42
0

This works for me

check this before:

echo %HOME%
echo %USERPROFILE%

and then:

set HOME=%USERPROFILE%
rsync .....
0

I solved this warning by creating 2 new folders inside my cwrsync folder.

<CWRSYNC FOLDER>/home/<USERNAME>

(First create home and then create a subfolder for your username.)

You can also create a directory junction (similar to a symlink) to your C:\Users\USERNAME folder, see @zizou13's answer on how to do this.

0

I simply made the home/admin directory that it wanted.

go.cmd

@ECHO OFF
SETLOCAL
SET PATH=c:\rsynclibrary\bin;c:\rsynclibrary\lib
mkdir c:\rsynclibrary\home
mkdir c:\rsynclibrary\home\admin
c:
cd \rsynclibrary
rsync -rtve "ssh -i ssh_key" --include-from=library.txt /cygdrive/c/ ...

ssh creates the .ssh directory and creates the known_hosts in c:\rsynclibrary\home\admin\.ssh

Works great.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.