windowssshlibcurl

Is there a definitive path for known hosts in Windows?


I'm working with libcurl as SFTP and its great. I want to check for the host am about to connect if it exists in the hosts file. In Linux I can easily find known hosts file as it is almost always in ~/.ssh/known_hosts. I wanted to know if Windows maintains the same thing or there is no standard as to where such file resides in Windows.


Solution

  • The ~/.ssh/known_hosts is a *nix path used by OpenSSH. The ~ is resolved to the account's home directory, which is specified in /etc/passwd file. The home defaults to /home/username folder on Linux.


    The OpenSSH is Linux software. It does not run on Windows on its own.

    Though it can run on *nix emulation on Windows and there are also Windows clones of OpenSSH. So in the end, your question is about what emulation or clone do you run on the Windows machine and how that maps/re-implements the access to ~/.ssh/known_hosts.


    Note that Windows SSH clients usually do not use the known_hosts. They have a different host key cache/storage.

    For example widely used Windows SSH client, PuTTY, stores know host keys to Windows registry to HKCU\Software\SimonTatham\PuTTY\SshHostKeys key. For details, see the answer by @aneesh.