Where is the known_hosts file for OpenSSH for Windows?

On windows it is usually stored in the %USERPROFILE%\ssh or %USERPROFILE%\.ssh folders. If you type %USERPROFILE% into the Windows explorer address bar it will be expanded automatically. You can also try cd /d "%USERPROFILE%\ssh" or cd /d "%USERPROFILE%\.ssh" from a command prompt.

Also see: https://stackoverflow.com/questions/32945533/is-there-a-definitive-path-for-known-hosts-in-windows


Had a similar issue not fixed with the user profile's known_hosts, so for anyone looking: If you have installed git, TortoiseGit, etc on Windows, the location of the overriding known_hosts file is in your git folder, e.g. Programs/Git/.ssh or Programs (x86)/Git/.ssh.

As per the error message

Add correct host key in /.ssh/known_hosts to get rid of this message.
Offending key in /.ssh/known_hosts:1

open the known_hosts file in an editor like Sublime with admin rights, remove the corresponding entry for your server in Programs/Git/.ssh/known_hosts and the new key fingerprint will get added on the next connection.

Tags:

Ssh

Powershell