Regarding "Host key verification Failed"

19,600

Solution 1

You can skip strict host key verification check using following command.

sshpass -p '<your_password>' ssh <your_server_ip> -o StrictHostKeyChecking=no

Note that above command will solve your problem when key is not present in /root/.ssh/known_host file, but if older key will be present than you have to remove that first by following command

ssh-keygen -R hostname

Solution 2

The first time you connect to another system you will be shown a fingerprint of the remote system's encryption key (which, if you're feeling paranoid, you can check offline).

On the remote system, the command ssh-keygen -lf /etc/ssh/ssh_host_rsa_key will show the fingerprint that should be shown the first time you connect to it.

When you confirm that this is the expected fingerprint, it is stored in the file $HOME/.ssh/known_hosts along with the name of the remote system, so that if you try and connect again and find the key has changed you are warned that the remote system has been changed, or your communications are being intercepted (unlikely, but still...).

In this case, you have maybe re-installed the remote system (so it has a new SSH key but the same name), and hence you are being warned that it has changed.

To correct this, you need to remove the existing entry from the known_hosts file. If you don't mind being asked again to confirm the identity of other machines you connect to, you can just delete known_hosts and it will be recreated the next time you use SSH. Alternatively, you can use the ssh-keygen command to delete the offending key, by doing ssh-keygen -R HOSTNAME (where HOSTNAME is the name of the remote machine).

Share:
19,600

Related videos on Youtube

bsreeram031187
Author by

bsreeram031187

Updated on September 18, 2022

Comments

  • bsreeram031187
    bsreeram031187 almost 2 years

    I use Ubuntu 10.04 in 2 virtual machines. In one machine I have installed Hudson and another machine is to run klocwork. Scenario is when I trigger a build in Hudson, the script has to run successful and call the Klocwork in VM2. In the build script I have given the following command to call Klocwork in machine 2.

    if [ $Klocwork = "true" ]; then
    echo "Starting Klocwork Report ..."
    sshpass -p 'password' ssh IP-address "sudo chmod 755 /local path/build_script_kw.sh;/local path/build_script_kw.sh $SVNID $Version"
    fi
    echo "Build Successfully."
    

    when I run the script, I get Host key verification failed error. Please provide me a solution for this issue. Thanks.

    • Rinzwind
      Rinzwind almost 12 years
      I found some information about this error notice here: askubuntu.com/questions/45679/… In short: your server key changed(?)
    • bsreeram031187
      bsreeram031187 almost 12 years
      could you please tell me how to check the key information????
  • chronitis
    chronitis almost 12 years
    After deleting known_hosts, the next time you connect to the remote computer you'll be asked to confirm the fingerprint is as expected (like the first time you connect to any new system). So connect to it once manually, then the script should work properly after that.