Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Failed to add the host to the list of known hosts" Windows prompt

I wanted to try and use git in my regular Windows prompt instead of in Git Bash. Simply for the reason that I could then use the terminal that IntelliJ provides. I figured it to be a 1 minute fix but I guess not.

When I try to git pull origin <branch> I get the following error message:

C:\Users\Username\Documents\Bitbucket\java-project>git pull
Could not create directory '/c/Username/.ssh'.
The authenticity of host 'bitbucket.org (131.103.20.167)' can't be established.
RSA key fingerprint is 12:8c:1b:f2:6d:14:6b:5c:3b:ec:aa:46:46:xy:7c:40.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/c/Username/.ssh/known_hosts).
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I have set the permissions on the existing .ssh folder such that all Users have full access, administrators and SYSTEM. So that should be okay.

I also tried to run the prompt as Administrator to see if that was the issue but that's not the case either.

What I do notice now is that it says: Could not create directory '/c/Username/.ssh'.. However, my .ssh directory is located at C:\Users\Username\.ssh. I might need to change my configuration then.

Git version: 1.9.0.msysgit.0 Windows version: Windows 8.1

like image 200
Christophe De Troyer Avatar asked May 31 '14 21:05

Christophe De Troyer


2 Answers

First of all, tested with msysgit 1.9.2, when one selects to make just git command available from cmd.exe during installation (where other choices are, make it avaiable only under git bash, or make all MSYS commands available under cmd.exe), git clone works from cmd.exe prompt.

The ssh client uses HOME environment variable to find .ssh/ directory, but git should take care of all the ugly details. You should not have HOME defined in your normal Windows environment, so if echo %HOME% in cmd.exe prompt prints a path, edit the OS environment variables and remove HOME.

If that does not solve it, uninstalling and installing latest version might help.


Finally, you have paths like C:UsersUsername, it probably means you're missing quotes somewhere. In git bash, try these two commands to see:

echo C:\Users\Username
echo 'C:\Users\Username'
like image 147
hyde Avatar answered Nov 19 '22 11:11

hyde


Make sure you type your cmd session the git-cmd.bat which comes with every Git For Windows msysgit release.

That will set your HOME to %USERPROFILE%, which should be C:\Users\Username.
But make sure you didn't have an environment variable HOME already defined with an incorrect value: unset it if that is the case.

like image 42
VonC Avatar answered Nov 19 '22 09:11

VonC