• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
NameHero® Blog

NameHero® Blog

Web Hosting Tips & Resources From NameHero

  • Hosting
    • Web Hosting
    • WordPress Hosting
    • WooCommerce Hosting
    • Enterprise Hosting
  • VPS
    • VPS Hosting
    • Flex VPS
  • Reseller
  • Email
  • Gaming
  • Domains
  • Website Builder
  • Account
  • Blog Home
  • Categories
  • Authors

How To Fix Host Key Verification Failed On Linux

CJ Saathoff

Published on: July 17, 2024

Categories: Linux Command Line 0

Have you gotten the error message “host key verification failed” when connecting to a remote server and are stuck wondering what it means and how to fix it? If so you have found your way to the right place. In this blog post, we will break down what the error means, possible causes, and the solution.

  • What Is SSH?
  • What Is A FQDN?
  • What Is Host Key Verification?
    • Possible Causes of The Error
  • Solutions
  • Conclusion
  • Additional Links

What Is SSH?

SSH stands for Secure Shell, it is one method for providing secure commutation over an untrusted network. It can be used for things like remote shell, file transferring, tunneling, and more.

What Is A FQDN?

FQDN stands for fully qualified domain name it is the full domain name assigned to the host for example server.example.com is an FQDN.

What Is Host Key Verification?

Host Key Verification is a security feature that is part of the SSH protocol. It is used to ensure the client you are connecting to is who they say they are. In other words, it is done to help prevent man-in-the-middle attacks.

When you connect to a server you have never connected to over SSH before you will get a message like this:

The authenticity of host ‘198.51.100.133 (198.51.100.133)’ can’t be established.

ED25519 key fingerprint is SHA256:*******************************************.

This key is not known by any other names.

Are you sure you want to continue connecting (yes/no/[fingerprint])?

  • Line 1: This tells us that it could not verify the authenticity of the host you are connecting to.
  • Line 2: Is information about the host key presented when opening the connection
  • Line 3: Tells us the key is not known by any other names. For example, if you connect to the server by a different IP or FQDN.
  • Line 4: The last line is a question, the question being do you want to continue connecting to the server even though the authenticity of the host could not be verified?

If you say yes, then the remote host key is stored in the ~/.ssh/known_hosts file after you log in using the password or SSH keys. That is then checked on when connecting to that host going forward.

Possible Causes of The Error

  • Server Reinstallation or UpgradeWas the Operating System reinstalled or Upgraded? These could cause the system’s host key to be regenerated.
  • Server Key RotationRotating the host key entry might be sometimes required in response to a cybersecurity incident.
  • Changes in DNS or IP AddressIs the FQDN being used pointing at the correct IP address?
  • Corrupt or Edited known_hosts FileBecause the known_hosts file contains the information stored on host keys if this file were edited or to become corrupt it could cause this error.
  • DNS Spoofing or Man-in-the-Middle AttackThis cause is the most concerning of the causes for this message. If someone were to gain control over the domain used to connect or hijack the traffic at a network level they could force you to connect to another server you’re not intending to connect to (possibly stealing login information for the real server in the process).

Solutions

  1. Verify the Server’s Authenticity:Before making changes the first thing you will want to do is to confirm you aren’t being tricked by a man-in-the-middle attack (aka making sure you are connecting to what you think you are connecting to).Assuming DNS is correct elsewhere, are you connecting from a trusted network connection? If you are not please try again from a trusted network. If a trusted network isn’t directly accessible a trusted VPN could be an option.
  2. Remove the Old Key:To remove the old key there are two options first is using ssh-keygen and the second is to manually remove the entries from the known_hosts file.Option 1: Using ssh-keygen run:ssh-keygen -R hostnameOption 2: To manually edit the known_hosts file open the file using your favorite text editor and remove the lines relating to the host you are having issues with.
  3. Connect AgainNow that the old host key has been removed you should be able to connect again and will be prompted to add the correct host key.

Conclusion

The security feature host key verification can help detect man-in-the-middle attacks when connecting to servers you have already connected to before. Although when things don’t work out it means that you will need to determine the cause before you continue. In this blog post, we discussed what the error means, possible causes, and the solution.

Additional Links

Done Reading and looking for things to read? Why not check these links out?

  • Other SSH-Related Posts
  • SSH Manual
CJ Saathoff

Embracing a lifelong passion for technology since childhood, CJ delved into the intricate workings of systems, captivated by the desire to understand the unknown. This innate curiosity led to his discovery of Linux, a revelation that resonated deeply. With more than 7 years of on the job experience, he’s honed his technical skills as a Geek and Senior Linux Systems Administrator.

Related Posts

How to Set Environment Variables in zsh

zsh is an alternative to bash and is similar to it in many ways. However, there's a difference in how to set environment variables in zsh.

What Is SIGSEGV and How Do We Fix It?

A SIGSEGV error is an error that the hardware throws to the operating system when a process attempts to access memory it shouldn't.

Demystifying The Bash Trap Command

In this blog post, we will demystify the trap command and help you perfectly implement the trap command into your bash scripts.

Compress and Conquer: A Comprehensive Guide To The Linux Zip Command

Check out our guide to learn everything you need to know about the Linux zip command - from basics to advanced use cases, we've got it all.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Follow & Subscribe

Exclusive promos, content and more!


Most Popular Posts

NameHero’s Recommended WordPress Plugin and Theme Setup (2024)

WordPress Hosting vs. Web Hosting – What’s The Difference?

How To Increase The InnoDB Buffer Pool Size

How To Fix A Stuck All-in-One WP Migration Import

How To Add A Subdomain In Cloudflare

Top Categories

  • WordPress
  • WordPress Tutorials
  • Enterprise Hosting
  • WooCommerce
  • Web Hosting
  • Resellers
  • Website Security
  • Website Development
  • Website Performance
  • VPS Hosting
  • SEO Tips
  • Announcements
  • Domain Registration
NameHero

NameHero® proudly provides web hosting to over 40,000 customers with 99.9% uptime to over 750,000 websites.

  • Master Card
  • Visa
  • American Express
  • Discover
  • Paypal
Products
  • Web Hosting
  • VPS Hosting
  • Flex VPS Hosting
  • WordPress Hosting
  • WooCommerce Hosting
  • Reseller Hosting
  • Enterprise Hosting
  • Email Hosting
  • Game Hosting
  • Domains
  • Website Builder
Help & Support
  • NameHero Blog
  • NameHero Gaming Blog
  • Support
  • Help Center
  • Migrations
  • Affiliates
  • Gaming Affiliates
  • Call 1-855-984-6263
Company
  • About Us
  • Contact Sales
  • Reviews
  • Uptime
  • We're Hiring

Copyright © 2025 Name Hero, LLC. All rights reserved.
NameHero® is a registered trademark.

  • Privacy Policy
  • Terms of Use
  • Acceptable Use Policy
  • Payment Policy
  • DMCA