aws server : paramiko issue
Question: while i can normally connect to a server with ssh command :

    
    
    >[ec2-user@dsi_valid_env:~/scripts]$ssh test@172.XX.YY.ZZ
    
    >test@172.XX.YY.ZZ's password:
    

but i am struggling to connect with paramiko for a python script :

    
    
    >>> import paramiko
    >>> ssh = paramiko.SSHClient()
    >>> ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    >>> ssh.connect("172.XX.YY.ZZ",username="test",password="test")
    
    paramiko.ssh_exception.SSHException: could not get keys from ssh-agent
    

do you have any idea of what i am doing wrong ?

below the debug stacktrace of my ssh.connect :

    
    
    ssh.connect("172.XX.YY.ZZ",username="test",password="test")
    DEBUG:paramiko.transport:starting thread (client mode): 0x24532d0L
    INFO:paramiko.transport:Connected (version 2.0, client OpenSSH_5.3)
    DEBUG:paramiko.transport:kex algos:[u'diffie-hellman-group-exchange-sha256', u'diffie-hellman-group-exchange-sha1', u'diffie-hellman-group14-sha1', u'diffie-hellman-group1-sha1'] server key:[u'ssh-rsa', u'ssh-dss'] client encrypt:[u'aes128-ctr', u'aes192-ctr', u'aes256-ctr', u'arcfour256', u'arcfour128', u'aes128-cbc', u'3des-cbc', u'blowfish-cbc', u'cast128-cbc', u'aes192-cbc', u'aes256-cbc', u'arcfour', u'rijndael-cbc@lysator.liu.se'] server encrypt:[u'aes128-ctr', u'aes192-ctr', u'aes256-ctr', u'arcfour256', u'arcfour128', u'aes128-cbc', u'3des-cbc', u'blowfish-cbc', u'cast128-cbc', u'aes192-cbc', u'aes256-cbc', u'arcfour', u'rijndael-cbc@lysator.liu.se'] client mac:[u'hmac-md5', u'hmac-sha1', u'umac-64@openssh.com', u'hmac-sha2-256', u'hmac-sha2-512', u'hmac-ripemd160', u'hmac-ripemd160@openssh.com', u'hmac-sha1-96', u'hmac-md5-96'] server mac:[u'hmac-md5', u'hmac-sha1', u'umac-64@openssh.com', u'hmac-sha2-256', u'hmac-sha2-512', u'hmac-ripemd160', u'hmac-ripemd160@openssh.com', u'hmac-sha1-96', u'hmac-md5-96'] client compress:[u'none', u'zlib@openssh.com'] server compress:[u'none', u'zlib@openssh.com'] client lang:[u''] server lang:[u''] kex follows?False
    DEBUG:paramiko.transport:Ciphers agreed: local=aes128-ctr, remote=aes128-ctr
    DEBUG:paramiko.transport:using kex diffie-hellman-group14-sha1; server key type ssh-rsa; cipher: local aes128-ctr, remote aes128-ctr; mac: local hmac-sha1, remote hmac-sha1; compression: local none, remote none
    DEBUG:paramiko.transport:Switch to new keys ...
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/lib/python2.6/dist-packages/paramiko/client.py", line 307, in connect
        look_for_keys, gss_auth, gss_kex, gss_deleg_creds, gss_host)
      File "/usr/lib/python2.6/dist-packages/paramiko/client.py", line 456, in _auth
        self._agent = Agent()
      File "/usr/lib/python2.6/dist-packages/paramiko/agent.py", line 339, in __init__
        self._connect(conn)
      File "/usr/lib/python2.6/dist-packages/paramiko/agent.py", line 68, in _connect
        raise SSHException('could not get keys from ssh-agent')
    paramiko.ssh_exception.SSHException: could not get keys from ssh-agent
    


Answer: I found the issue,

i changed :

    
    
    ssh.connect("172.XX.YY.ZZ",username="test",password="test")
    

to:

    
    
    ssh.connect("172.XX.YY.ZZ",username="test",password="test", allow_agent=False)
    

apparently the switch to "password authentification" is not fully automatic in
some cases

