Host Key Verification Failed When Using SSH_Exec(OpenSSH).vi

Updated Jan 4, 2023

Reported In

Software

  • LabVIEW 2021
  • LabVIEW 2022 Q3

Issue Details

I'm trying to send a command to a server through OpenSSH using SSH_Exec(OpenSSH).vi included in NI_SSH.lvlib. All the required inputs are set correctly, but I received "Host Key Verification Failed" as standard error and 255 as return code.
 
image.png
How can I fix this issue?

Solution

The host key verification error occurs when the key of the remote server is not cached and the client does not find it from the stored keys.

The host keys are stored in C:\Users\username\.ssh\know_hosts, opening the file with a Text Editor (such as Notepad) will show all the keys cached for each IP address.

The SSH_Exec(OpenSSH).vi doesn't cache the host key and doesn't ask if the user wants to store it. In order to use this VI, it is necessary first open PowerShell or PuTTY and run the command ssh user@IP_Address, it will prompt the question below, then type yes.
 
putty.PNG

This workaround will store the host key in know_hosts file and allow to run the SSH_Exec VI to communicate through SSH communication with the server.