OpenSSH Windows Known_hosts Problem and SSH-Keygen work around
Posted by: admin in Linux, WindowsI have been trying to fix this error:
Could not create directory ‘/home/xxx/.ssh’.
The authenticity of host can’t be established.
Failed to add the host to the list of known hosts (/home/xxx/.ssh/known_hosts)
It is very annoying to type in Yes everytime trying to connect to a server so I decided to do some research but couldn’t find solution.
I found my solution this way:
-Create a file in your hard drive (wherever you feel like), I have created mine under: c:\users\myusername\known_hosts (ex: c:\users\john\known_hosts)
-find ssh_config under OpenSSH\etc\ folder and add this line
UserKnownHostsFile c:/users/john/known_hosts
After you add this line, try to connect and you won’t have to type in “Yes” anymore. If you would like to disable known_hosts file check completely, you can also change this line:
StrictHostKeyChecking yes
to
StrictHostKeyChecking no
That will allow you avoid known_hosts from get go.
If you want to do public key authentication but you are not able to use ssh-keygen to create because you are getting:
Generating public/private rsa key pair.
Enter file in which to save the key (/home/xxx/.ssh/id_rsa):
Could not create directory ‘/home/xxx/.ssh’.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
open /home/xxx/.ssh/id_rsa failed: No such file or directory.
Saving the key failed: /home/xxx/.ssh/id_rsa.
You can run ssh-keygen uder c:\program files\openssh\bin\ folder with this:
ssh-keygen -t rsa -f id_rsa
-f switch would allow you to add a filename. Once you create the public and private key (for this example: id_rsa and id_rsa.pub) go back to your c:\program files\openssh\etc\ssh_config file and remove # from
#IdentityFile ~/.ssh/id_rsa
and point it to your new file:
IdentityFile c:/program files/openssh/bin/id_rsa
Entries (RSS)