This is an old revision of the document!


Known Hosts Error

When you are working on a new computer, it is possible that the computer is unaware of the Git host that you are using. Git imposes a security precaution: It does not know if your repository is being handled by the correct host, the one you had intended. For example; a hacker may maliciously setup a Git host and somehow convince you to send the repository to that fake Git host instead of the one you wanted.

To prevent this, Git looks inside a file called “known_hosts” This is present in the .ssh folder of your user profile directory in Windows. If that file is not available, Git will cry out loud and generate this error about known_hosts

To remove this error, you have to let your computer detect carry out a proper “handshake” with the Git host you wanted to use. We have made this process easy.

  • Go to the application folder of Git Winch
  • Open the Windows CMD window there
  • Write down the following and press ENTER:

setknownhost.bat gitlab.com

The above batch file command you need to run is for gitlab.com … For github.com you will have to give

setknownhost.bat github.com

If you have custom Git Host (e.g. you hosted your own Gitea or Gitlab) then you will need to change the argument of that .bat file to the domain name of that Git Host.

knownhosts.1753966151.txt.gz · Last modified: by admin