mysqlpostgresqlremote-servernavicatknown-hosts

Navicat doesn't recognize new entries in known_hosts file on Mac and cannot connect to remote server


UPDATE Feb 2022: this issue may have been fixed in more recent versions. See comments on the accepted solution.

Summary:

An existing connection to a remote database in Navicat was working using a domain name for the SSH > Host field. After building a new remote server and pointing the domain at the new IP address (and setting up the database and users, as well as adding your public RSA key to the new server), Navicat doesn't trust the key hash from the server. Replacing the entries in ~/.ssh/known_hosts doesn't help.

Steps to reproduce:

Expected:

Actual:

Error:

The server key has changed. Either you are under attack or the administrator changed the key.
New server key hash:...

Question:

How to get Navicat to accept the new known_hosts data and authorize the connection?


Solution

  • Problem:

    Navicat uses a different known_hosts file than the operating system does. So updating ~/.ssh/known_hosts doesn't affect the Navicat connection to the remote server.

    Solution:

    1. Optional workaround:
      • in Navicat, edit the database connection
      • on the SSH tab, change the Host field from a domain to the new IP address
    2. Fix:
      • in Terminal, run sudo find ~ -name known_hosts
      • the results will include something like (using Navicat Essentials for PostgreSQL as an example): /Users/<user>/Library/Containers/com.prect.NavicatEssentialsForPostgreSQL12/Data/.ssh/known_hosts
      • edit that file and remove the line starting with the domain for your remote server
      • return to Navicat and click Test Connection again. The connection should work.
      • If you see the error: Access denied for 'publickey'. Authentication that can continue: publickey,password (101203) or similar, check the Authentication Method selection and, if you're using 'Public Key' or 'Password and Public Key', click the 'Private Key' file navigator and re-select one of the private keys matching a public key that you've added to the remote server.