title: Host key mismatch
body: <p>I am trying to connect to a remote server using Go. This is what I am using: (<a href="https://stackoverflow.com/questions/45441735/ssh-handshake-complains-about-missing-host-key">SSH Handshake complains about missing host key</a>)</p>
  
  <pre><code>    key, err := ioutil.ReadFile("/Users/pankaj/.ssh/id_rsa")                                                                
      if err != nil {                                                                                                         
          log.Fatalf("unable to read private key: %v", err)                                                                   
      }                                                                                                                       
  
      // Create the Signer for this private key.                                                                              
      signer, err := ssh.ParsePrivateKey(key)                                                                                 
      if err != nil {                                                                                                         
          log.Fatalf("unable to parse private key: %v", err)                                                                  
      }        
  
      hostKeyCallback, err := knownhosts.New("/Users/pankaj/.ssh/known_hosts")
      if err != nil {
          log.Fatal(err)
      }
  
      sshConfig := &amp;ssh.ClientConfig{
          User: "pankaj",
          Auth: []ssh.AuthMethod{
              ssh.PublicKeys(signer),
          },
          HostKeyCallback: hostKeyCallback,
      }
  
      conn, err := ssh.Dial("tcp", "dev.letsreap.com:22", sshConfig) 
      if err != nil {                                                                                                         
          log.Fatalf("unable to connect: %v", err)                                                                            
      } 
  </code></pre>
  
  <p>However on ssh.Dial I am getting:</p>
  
  <pre><code>ssh: handshake failed: knownhosts: key mismatch
  </code></pre>
  
  <p>I have verified that I can connect to the remote server from the command line. Also I can connect successfully if I use ssh.InsecureIgnoreHostKey(). What am I missing?</p>