<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Ssh on The Network Stack</title>
    <link>https://thenetworkstack.com/tags/ssh/</link>
    <description>Recent content in Ssh on The Network Stack</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Sat, 27 Jan 2018 18:58:42 +0000</lastBuildDate>
    <atom:link href="https://thenetworkstack.com/tags/ssh/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Ansible - BadHostKeyException</title>
      <link>https://thenetworkstack.com/ansible-badhostkeyexception/</link>
      <pubDate>Sat, 27 Jan 2018 18:58:42 +0000</pubDate>
      <guid>https://thenetworkstack.com/ansible-badhostkeyexception/</guid>
      <description>&lt;p&gt;When executing an ansible playbook, you may get the following error:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;An exception occurred during task execution. To see the full traceback, use -vvv. The error was: paramiko.BadHostKeyException: Host key &lt;span class=&#34;k&#34;&gt;for&lt;/span&gt; server switch-name does not match!
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This probably happened after you changed the name of your network device, and generated new RSA keys.  Or, if you are using DNS device names in ansible, resolve the name of your network device from your ansible server and verify the DNS resolution is correct.  To fix the issue, edit your &amp;ldquo;known_hosts&amp;rdquo; file and remove the key associated with the network device throwing the error:&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>When executing an ansible playbook, you may get the following error:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">An exception occurred during task execution. To see the full traceback, use -vvv. The error was: paramiko.BadHostKeyException: Host key <span class="k">for</span> server switch-name does not match!
</span></span></code></pre></div><p>This probably happened after you changed the name of your network device, and generated new RSA keys.  Or, if you are using DNS device names in ansible, resolve the name of your network device from your ansible server and verify the DNS resolution is correct.  To fix the issue, edit your &ldquo;known_hosts&rdquo; file and remove the key associated with the network device throwing the error:</p>
<ol>
<li>Open your known_hosts file</li>
</ol>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">vi ~/.ssh/known_hosts
</span></span></code></pre></div><ol>
<li>Search for the line with the network device RSA key</li>
</ol>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">/network_device_name
</span></span></code></pre></div><ol>
<li>Delete the RSA key for that network device (&ldquo;dd&rdquo; deletes the entire line)</li>
</ol>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">dd
</span></span></code></pre></div><ol>
<li>Save the known_hosts file</li>
</ol>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="c1">#Press the escape key first</span>
</span></span><span class="line"><span class="cl">:wq
</span></span></code></pre></div><p>If you don&rsquo;t want ansible to perform this check, edit your <strong>ansible.cfg</strong> file with:</p>
<pre tabindex="0"><code>host_key_checking = False
</code></pre>]]></content:encoded>
    </item>
  </channel>
</rss>
