Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>More generally, if you get this error, you should try SSHing with the exact parameters that paramiko is trying to use:</p> <ul> <li>hostname</li> <li>user</li> <li>authentication method</li> </ul> <p>I found that having too many SSH keys caused <em>some</em> (but not all) of my fabric SSH connections to fail, because all the keys were being offered to the remote host. In the past, malformed keys have also raised this error message for me (you can detect them by removing the keys from <code>~/.ssh/</code> , one at a time.)</p> <p>Unfortunately, Fabric doesn't respect your .ssh/config settings. If you want to debug this, you can run the following:</p> <pre><code>#!/usr/bin/env python import paramiko paramiko.util.log_to_file("/tmp/paramiko.log") ssh = paramiko.SSHClient() # Run this if you get host key errors: see later ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect("example.com", username="myuser", password="mypassword") </code></pre> <p>and check the output in <code>/tmp/paramiko.log</code> - you might see something like:</p> <pre><code>INF [20120904-16:58:52.155] thr=1 paramiko.transport: Disconnect (code 2): Too many authentication failures for myuser </code></pre> <p>You can <a href="http://docs.fabfile.org/en/1.4.2/usage/env.html#no-keys" rel="nofollow">set no_keys on the Fabric env environment</a>:</p> <pre><code>env.no_keys = True </code></pre> <p>But then you will need to tell Fabric to use specific keys for specific hosts. As suggested above, you can do that in your fabfile with:</p> <pre><code>from fabric.api import env env.key_filename = "/path/to/.ssh/ssk_non_public_key" </code></pre> <p>More generally <a href="http://markpasc.typepad.com/blog/2010/04/loading-ssh-config-settings-for-fabric.html" rel="nofollow">here's a function to parse your .ssh config and pull out selective keys</a> - in this keys, the SSH key to use. For this to work automatically, you'll need to add IdentityFile to <code>~/.ssh/config</code>:</p> <pre><code>Host example.com IdentityFile /home/jp/.ssh/id_rsa_example </code></pre> <p>Another cause of failure might be that <a href="https://github.com/paramiko/paramiko/issues/46" rel="nofollow">paramiko does not recognize all host key types</a>. This is somewhat more problematic: paramiko is quietly ignoring the host key in <code>~/.ssh/known_hosts</code>, because it's not a format of host key that it understands. Try ssh-ing with -v and see what line SSH says it finds a host key match for:</p> <pre><code>debug1: Host '1.2.3.4' is known and matches the RSA host key. debug1: Found key in /home/jp/.ssh/known_hosts:105 </code></pre> <p>You can try deleting this line, then doing ssh again and accepting the (new?) host key, and see if paramiko is happy then. If that's the problem, though, and that doesn't solve it, then there's no clear solution that I can see.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload