惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Y
Y Combinator Blog
S
SegmentFault 最新的问题
WordPress大学
WordPress大学
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
美团技术团队
博客园 - 叶小钗
大猫的无限游戏
大猫的无限游戏
罗磊的独立博客
Hugging Face - Blog
Hugging Face - Blog
博客园 - 司徒正美
小众软件
小众软件
博客园 - 聂微东
阮一峰的网络日志
阮一峰的网络日志
博客园 - 三生石上(FineUI控件)
月光博客
月光博客
The Cloudflare Blog
T
Tailwind CSS Blog
博客园 - 【当耐特】
Jina AI
Jina AI
量子位
有赞技术团队
有赞技术团队
博客园 - Franky
V
Visual Studio Blog
V
V2EX

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
known_hosts
Erick Quinteros · 2026-06-01 · via DEV Community

Erick Quinteros

1. Introduction

As the golden standard of secure remote access, the Secure Shell (SSH) protocol has several layers of protection. One of them involves recording and keeping track of the known servers on the client side.

known_hosts

By default, the known_hosts file for a given user is located at:

cat /home/user_name/.ssh/known_hosts 
github.com ssh-rsa 
***
github.com ecdsa-sha2-nistp256 ***
github.com ssh-ed25519 ***

Basically, the file contains a list with several columns, separated by whitespace:

  1. Identifying host data
  2. Host key type
  3. Host key value
  4. Optional comment The first column can be hashed or cleartext, depending on the setting of HashKnownHosts in /etc/ssh/ssh_config. When hashed, the first field of each line starts with |1|, a HASH_MAGIC marker. After the latter, the field continues with a random 160-bit string, otherwise known as a salt, followed by a 160-bit SHA1 hash. Each of these is encoded in base64. The main idea is to hide the IP address or hostname data, which would otherwise be directly visible Either way, known_hosts contains a mapping between a server as identified by its characteristics and its key. ## Known Hosts Checking When connecting to a remote host, SSH checks the known_hosts file of the client to confirm the address or hostname for the server match the key we get from it. If there is a match, the session setup can continue. Otherwise, we get an error. The entry for 192.168.6.66 in the known_hosts file doesn’t match the (Elliptic Curve Digital Signature Algorithm, ECDSA) key we got back from the server at that address. Critically, if we don’t know what caused the error, we should heed the text in capital letters: something nasty can indeed be happening. On the other hand, the reasons for such an issue can be valid and trivial:
  5. dynamic IP address
  6. changed hostname
  7. reinstalled system
  8. reinstalled SSH
  9. Docker container
  10. misconfigured DHCP
  11. relocated client In fact, there can be many more. ## Bypass Known Hosts The error text when connecting to a misidentified host tells us a few remedies for the situation. ### Correct the Row Since we already know which row of the known_hosts file doesn’t match (the suffix :1 of /home/erickquinteros/.ssh/known_hosts:1), we can correct the host data, key type, and value. By default, there are several host keys:
  12. /etc/ssh/ssh_host_rsa_key
  13. /etc/ssh/ssh_host_ecdsa_key
  14. /etc/ssh/ssh_host_ed25519_key ### Remove the Row If we trust the host and don’t want to bother correcting the line by hand, we can simply remove the entry with the supplied command:
ssh-keygen -f "/home/user_name/.ssh/known_hosts" -R "github.com"
# Host github.com found: line 1
# Host github.com found: line 2
# Host github.com found: line 3
/home/user_name/.ssh/known_hosts updated.
Original contents retained as /home/user_name/.ssh/known_hosts.old

Permanently Ignore

Another way to bypass the host checks is by adding a Host statement for the offending server in our ssh_config:
We can disable several checks:

  • StrictHostKeyChecking no means we won’t need a match to connect to a server
  • UserKnownHostsFile /dev/null_ overrides our default known_hosts path with the empty /dev/null
  • GlobalKnownHostsFile /dev/null overrides the default global known hosts file path again with the empty /dev/null Essentially, this combination of three options strips the security of hosts checking and prevents additions to the known_hosts files for a given machine. ### Temporarily Ignore We may want to ignore the known hosts only temporarily:
$ ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o GlobalKnownHostsFile=/dev/null 192.168.6.66

Directly pass each of the options via -o flags when connecting to the misidentified server. Doing so enables easier debugging without global changes to the configuration.

Bibliography

What Is the SSH known_hosts File and How to Temporarily Ignore It

Further Reading

Check out the other articles in this series:

  • ssh-agent:
  • ssh-keygen:

    What Is ssh-keygen




          <a href="/erixero" class="crayons-avatar  crayons-avatar--l  ">
            <img src="https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3961631%2F3bda9bbb-8de7-466f-a410-f81e413413b6.jpg" alt="erixero profile" class="crayons-avatar__image" loading="lazy" />
          </a>
        </div>
        <div>
          <div>
            <a href="/erixero" class="crayons-story__secondary fw-medium m:hidden">
              Erick Quinteros
            </a>
            <div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block">
              <button id="story-author-preview-trigger-3791024" aria-controls="story-author-preview-content-3791024" class="profile-preview-card__trigger fs-s p-1 -ml-1 -my-2 crayons-btn crayons-btn--ghost" aria-label="Erick Quinteros profile details">
                Erick Quinteros
    
              </button>
              <div
                id="story-author-preview-content-3791024"
                class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"
                style="border-top-color: var(--card-color);"
                data-repositioning-dropdown="true"
                data-testid="profile-preview-card">
                <div class="gap-4 grid">
                  <div class="-mt-4">
                    <a href="/erixero" class="flex">
                      <span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0">
                        <img
                          src="https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3961631%2F3bda9bbb-8de7-466f-a410-f81e413413b6.jpg"
                          class="crayons-avatar__image"
                          alt=""
                          loading="lazy" />
                      </span>
                      <span class="crayons-link crayons-subtitle-2 mt-5">Erick Quinteros</span>
                    </a>
                  </div>
                  <div class="print-hidden">
                    <button
                      class="crayons-btn follow-action-button whitespace-nowrap follow-user w-100"
                      data-info='{&quot;style&quot;:&quot;full&quot;,&quot;id&quot;:3961631,&quot;className&quot;:&quot;User&quot;,&quot;name&quot;:&quot;Erick Quinteros&quot;}'>
                      Follow
                    </button>
                  </div>
                  <div
                    class="author-preview-metadata-container"
                    data-author-id="3961631"></div>
                </div>
              </div>
            </div>
    
          </div>
          <a href="https://dev.to/erixero/what-is-ssh-keygen-17dl" class="crayons-story__tertiary fs-xs"><time datetime="2026-05-31T20:26:19Z">May 31</time><span class="time-ago-indicator-initial-placeholder" data-seconds="1780259179"></span></a>
        </div>
      </div>
    
    </div>
    
    <div class="crayons-story__indention">
      <h2 class="crayons-story__title crayons-story__title-full_post">
        <a href="https://dev.to/erixero/what-is-ssh-keygen-17dl" data-preload-image="" id="article-link-3791024">
          What Is ssh-keygen
        </a>
      </h2>
        <div class="crayons-story__tags">
            <a class="crayons-tag  crayons-tag--monochrome " style="
        --tag-bg: rgba(59, 73, 223, 0.10);
        --tag-prefix: #3b49df;
        --tag-bg-hover: rgba(59, 73, 223, 0.10);
        --tag-prefix-hover: #3b49df;
      " href="/t/ssh"><span class="crayons-tag__prefix">#</span>ssh</a>
            <a class="crayons-tag  crayons-tag--monochrome " style="
        --tag-bg: rgba(59, 73, 223, 0.10);
        --tag-prefix: #3b49df;
        --tag-bg-hover: rgba(59, 73, 223, 0.10);
        --tag-prefix-hover: #3b49df;
      " href="/t/keygen"><span class="crayons-tag__prefix">#</span>keygen</a>
            <a class="crayons-tag  crayons-tag--monochrome " style="
        --tag-bg: rgba(59, 73, 223, 0.10);
        --tag-prefix: #3b49df;
        --tag-bg-hover: rgba(59, 73, 223, 0.10);
        --tag-prefix-hover: #3b49df;
      " href="/t/authentication"><span class="crayons-tag__prefix">#</span>authentication</a>
            <a class="crayons-tag  crayons-tag--monochrome " style="
        --tag-bg: rgba(59, 73, 223, 0.10);
        --tag-prefix: #3b49df;
        --tag-bg-hover: rgba(59, 73, 223, 0.10);
        --tag-prefix-hover: #3b49df;
      " href="/t/cheatsheet"><span class="crayons-tag__prefix">#</span>cheatsheet</a>
        </div>
      <div class="crayons-story__bottom">
        <div class="crayons-story__details">
            <a href="https://dev.to/erixero/what-is-ssh-keygen-17dl#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center" aria-label="Add a comment to post - What Is ssh-keygen">
              <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" role="img" aria-labelledby="a1lacq2zri2n04ht4k519482sxr72odk" class="crayons-icon"><title id="a1lacq2zri2n04ht4k519482sxr72odk">Comments</title><path d="M10.5 5h3a6 6 0 110 12v2.625c-3.75-1.5-9-3.75-9-8.625a6 6 0 016-6zM12 15.5h1.5a4.501 4.501 0 001.722-8.657A4.5 4.5 0 0013.5 6.5h-3A4.5 4.5 0 006 11c0 2.707 1.846 4.475 6 6.36V15.5z"></path></svg>
    
              <span class="hidden s:inline">Add Comment</span>
            </a>
        </div>
        <div class="crayons-story__save">
          <small class="crayons-story__tertiary fs-xs mr-2">
            3 min read
          </small>
            <button
              type="button"
              id="article-save-button-3791024"
              class="c-btn c-btn--icon-alone bookmark-button"
              data-reactable-id="3791024"
              data-article-author-id="3961631"
              aria-label="Save post What Is ssh-keygen to reading list"
              title="Save post What Is ssh-keygen to reading list">
              <span class="bm-initial">
                <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" aria-hidden="true"><path d="M6.75 4.5h10.5a.75.75 0 01.75.75v14.357a.375.375 0 01-.575.318L12 16.523l-5.426 3.401A.375.375 0 016 19.607V5.25a.75.75 0 01.75-.75zM16.5 6h-9v11.574l4.5-2.82 4.5 2.82V6z"></path></svg>
    
              </span>
              <span class="bm-success">
                <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" aria-hidden="true"><path d="M6.75 4.5h10.5a.75.75 0 01.75.75v14.357a.375.375 0 01-.575.318L12 16.523l-5.426 3.401A.375.375 0 016 19.607V5.25a.75.75 0 01.75-.75z"></path></svg>
    
              </span>
            </button>
        </div>
      </div>
    </div>
    


  • known_hosts:

    known_hosts




          <a href="/erixero" class="crayons-avatar  crayons-avatar--l  ">
            <img src="https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3961631%2F3bda9bbb-8de7-466f-a410-f81e413413b6.jpg" alt="erixero profile" class="crayons-avatar__image" loading="lazy" />
          </a>
        </div>
        <div>
          <div>
            <a href="/erixero" class="crayons-story__secondary fw-medium m:hidden">
              Erick Quinteros
            </a>
            <div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block">
              <button id="story-author-preview-trigger-3791248" aria-controls="story-author-preview-content-3791248" class="profile-preview-card__trigger fs-s p-1 -ml-1 -my-2 crayons-btn crayons-btn--ghost" aria-label="Erick Quinteros profile details">
                Erick Quinteros
    
              </button>
              <div
                id="story-author-preview-content-3791248"
                class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"
                style="border-top-color: var(--card-color);"
                data-repositioning-dropdown="true"
                data-testid="profile-preview-card">
                <div class="gap-4 grid">
                  <div class="-mt-4">
                    <a href="/erixero" class="flex">
                      <span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0">
                        <img
                          src="https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3961631%2F3bda9bbb-8de7-466f-a410-f81e413413b6.jpg"
                          class="crayons-avatar__image"
                          alt=""
                          loading="lazy" />
                      </span>
                      <span class="crayons-link crayons-subtitle-2 mt-5">Erick Quinteros</span>
                    </a>
                  </div>
                  <div class="print-hidden">
                    <button
                      class="crayons-btn follow-action-button whitespace-nowrap follow-user w-100"
                      data-info='{&quot;style&quot;:&quot;full&quot;,&quot;id&quot;:3961631,&quot;className&quot;:&quot;User&quot;,&quot;name&quot;:&quot;Erick Quinteros&quot;}'>
                      Follow
                    </button>
                  </div>
                  <div
                    class="author-preview-metadata-container"
                    data-author-id="3961631"></div>
                </div>
              </div>
            </div>
    
          </div>
          <a href="https://dev.to/erixero/knownhosts-40f0" class="crayons-story__tertiary fs-xs"><time datetime="2026-05-31T21:31:02Z">May 31</time><span class="time-ago-indicator-initial-placeholder" data-seconds="1780263062"></span></a>
        </div>
      </div>
    
    </div>
    
    <div class="crayons-story__indention">
      <h2 class="crayons-story__title crayons-story__title-full_post">
        <a href="https://dev.to/erixero/knownhosts-40f0" data-preload-image="" id="article-link-3791248">
          known_hosts
        </a>
      </h2>
        <div class="crayons-story__tags">
            <a class="crayons-tag  crayons-tag--monochrome " style="
        --tag-bg: rgba(59, 73, 223, 0.10);
        --tag-prefix: #3b49df;
        --tag-bg-hover: rgba(59, 73, 223, 0.10);
        --tag-prefix-hover: #3b49df;
      " href="/t/ssh"><span class="crayons-tag__prefix">#</span>ssh</a>
            <a class="crayons-tag  crayons-tag--monochrome " style="
        --tag-bg: rgba(59, 73, 223, 0.10);
        --tag-prefix: #3b49df;
        --tag-bg-hover: rgba(59, 73, 223, 0.10);
        --tag-prefix-hover: #3b49df;
      " href="/t/knownhosts"><span class="crayons-tag__prefix">#</span>knownhosts</a>
            <a class="crayons-tag  crayons-tag--monochrome " style="
        --tag-bg: rgba(59, 73, 223, 0.10);
        --tag-prefix: #3b49df;
        --tag-bg-hover: rgba(59, 73, 223, 0.10);
        --tag-prefix-hover: #3b49df;
      " href="/t/authentication"><span class="crayons-tag__prefix">#</span>authentication</a>
            <a class="crayons-tag  crayons-tag--monochrome " style="
        --tag-bg: rgba(59, 73, 223, 0.10);
        --tag-prefix: #3b49df;
        --tag-bg-hover: rgba(59, 73, 223, 0.10);
        --tag-prefix-hover: #3b49df;
      " href="/t/cheatsheet"><span class="crayons-tag__prefix">#</span>cheatsheet</a>
        </div>
      <div class="crayons-story__bottom">
        <div class="crayons-story__details">
            <a href="https://dev.to/erixero/knownhosts-40f0#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center" aria-label="Add a comment to post - known_hosts">
              <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" role="img" aria-labelledby="aqugdlvrezjttx1hicdkyogm9n41rh9r" class="crayons-icon"><title id="aqugdlvrezjttx1hicdkyogm9n41rh9r">Comments</title><path d="M10.5 5h3a6 6 0 110 12v2.625c-3.75-1.5-9-3.75-9-8.625a6 6 0 016-6zM12 15.5h1.5a4.501 4.501 0 001.722-8.657A4.5 4.5 0 0013.5 6.5h-3A4.5 4.5 0 006 11c0 2.707 1.846 4.475 6 6.36V15.5z"></path></svg>
    
              <span class="hidden s:inline">Add Comment</span>
            </a>
        </div>
        <div class="crayons-story__save">
          <small class="crayons-story__tertiary fs-xs mr-2">
            3 min read
          </small>
            <button
              type="button"
              id="article-save-button-3791248"
              class="c-btn c-btn--icon-alone bookmark-button"
              data-reactable-id="3791248"
              data-article-author-id="3961631"
              aria-label="Save post known_hosts to reading list"
              title="Save post known_hosts to reading list">
              <span class="bm-initial">
                <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" aria-hidden="true"><path d="M6.75 4.5h10.5a.75.75 0 01.75.75v14.357a.375.375 0 01-.575.318L12 16.523l-5.426 3.401A.375.375 0 016 19.607V5.25a.75.75 0 01.75-.75zM16.5 6h-9v11.574l4.5-2.82 4.5 2.82V6z"></path></svg>
    
              </span>
              <span class="bm-success">
                <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" aria-hidden="true"><path d="M6.75 4.5h10.5a.75.75 0 01.75.75v14.357a.375.375 0 01-.575.318L12 16.523l-5.426 3.401A.375.375 0 016 19.607V5.25a.75.75 0 01.75-.75z"></path></svg>
    
              </span>
            </button>
        </div>
      </div>
    </div>