One of the servers I frequently log into via SSH has changed it's IP address. So, now I'm getting man in the middle attack warnings when I try to use SSH via Windows Powershell and OpenSSH for Windows.

On a linux machine, I would just remove the offending line from ~/.ssh/known_hosts. But, the ~/.ssh directory seems to be empty.

Where is the known_hosts file for Powershell/OpenSSH? I've checked in C:\Program Files\OpenSSH\home\anschauung\.ssh, but that folder is empty as well.

  • 1
    Don't remove it. Update the line to change the IP address from the old one to the new one to avoid opening a window for an attacker to impersonate the host.
    – cjs
    Dec 12, 2016 at 2:07

2 Answers 2


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

  • On linux there is also a system level file - /etc/ssh/ssh_known_hosts. Is there an equivalent for windows? May 3 at 7:10

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.

  • For me: C:\Users[My User]\AppData\Local\VirtualStore\Program Files (x86)\Git\.ssh
    – Dunc
    Sep 7, 2015 at 11:05
  • 1
    I do not have that ssh directory in C:\Program Files\Git. This answer is perhaps outdated? Mar 11, 2021 at 21:16

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.