2016-11-11 12 views
0

最近のトラブルシューティング中に、私のpython環境にいくつかの変更が発生しました。私は権利のすべてに戻っている印象を受けていますが、それは必ずしもそうでないかもしれません。 非常に簡単なテストを含む私のfabコマンドはすべて失敗しているようです。 paramikoのキー操作/ユーザーパスフォールバックの問題であるかのようです。ファブリックがparamikoの認証問題に遭遇しました

#!/usr/bin/env python 

from fabric.api import * 
from fabric import exceptions 
import paramiko 
from sys import argv 
import re 
import os 
import getpass 

import logging 
logging.basicConfig(level=logging.DEBUG) 

failed_hosts = {} 

def run_command(Command): 
    try: 
#  print_env('run_command', Command) 
#  print_transport() 
     output = run(Command, shell = False) 
     return output 
    except exceptions.NetworkError as e: 
     print "Error encountered for %s: %s" % (env.host_string, e) 
     failed_hosts[env.host_string] = e 

def test_ver(): 
    result=run_command('sh ver') 
    print result 

私が手::

ca-cmacnevi-mac:~ christian.macnevin$ fab -f fabtest.py test_ver -u admin No hosts found. Please specify (single) host string for connection: cisco_switch [cisco_switch] run: sh ver DEBUG:paramiko.transport:starting thread (client mode): 0x3d9da90L DEBUG:paramiko.transport:Local version/idstring: SSH-2.0-paramiko_1.17.2 DEBUG:paramiko.transport:Remote version/idstring: SSH-2.0-Cisco-1.25 INFO:paramiko.transport:Connected (version 2.0, client Cisco-1.25) DEBUG:paramiko.transport:kex algos:[u'diffie-hellman-group1-sha1'] server key:[u'ssh-rsa'] client encrypt:[u'aes128-cbc', u'3des-cbc', u'aes192-cbc', u'aes256-cbc'] server encrypt:[u'aes128-cbc', u'3des-cbc', u'aes192-cbc', u'aes256-cbc'] client mac:[u'hmac-sha1', u'hmac-sha1-96', u'hmac-md5', u'hmac-md5-96'] server mac:[u'hmac-sha1', u'hmac-sha1-96', u'hmac-md5', u'hmac-md5-96'] client compress:[u'none'] server compress:[u'none'] client lang:[u''] server lang:[u''] kex follows?False DEBUG:paramiko.transport:Kex agreed: diffie-hellman-group1-sha1 DEBUG:paramiko.transport:Cipher agreed: aes128-cbc DEBUG:paramiko.transport:MAC agreed: hmac-md5 DEBUG:paramiko.transport:Compression agreed: none DEBUG:paramiko.transport:kex engine KexGroup1 specified hash_algo DEBUG:paramiko.transport:Switch to new keys ... DEBUG:paramiko.transport:Trying SSH agent key d0f5d22e756685a3640d3a24ec18bb6c DEBUG:paramiko.transport:userauth is OK DEBUG:paramiko.transport:Authentication type (publickey) not permitted. DEBUG:paramiko.transport:Allowed methods: [u'password'] [cisco_switch] Passphrase for private key: DEBUG:paramiko.transport:starting thread (client mode): 0x3dc6e50L DEBUG:paramiko.transport:Local version/idstring: SSH-2.0-paramiko_1.17.2 DEBUG:paramiko.transport:Remote version/idstring: SSH-2.0-Cisco-1.25 INFO:paramiko.transport:Connected (version 2.0, client Cisco-1.25) DEBUG:paramiko.transport:kex algos:[u'diffie-hellman-group1-sha1'] server key:[u'ssh-rsa'] client encrypt:[u'aes128-cbc', u'3des-cbc', u'aes192-cbc', u'aes256-cbc'] server encrypt:[u'aes128-cbc', u'3des-cbc', u'aes192-cbc', u'aes256-cbc'] client mac:[u'hmac-sha1', u'hmac-sha1-96', u'hmac-md5', u'hmac-md5-96'] server mac:[u'hmac-sha1', u'hmac-sha1-96', u'hmac-md5', u'hmac-md5-96'] client compress:[u'none'] server compress:[u'none'] client lang:[u''] server lang:[u''] kex follows?False DEBUG:paramiko.transport:Kex agreed: diffie-hellman-group1-sha1 DEBUG:paramiko.transport:Cipher agreed: aes128-cbc DEBUG:paramiko.transport:MAC agreed: hmac-md5 DEBUG:paramiko.transport:Compression agreed: none DEBUG:paramiko.transport:kex engine KexGroup1 specified hash_algo DEBUG:paramiko.transport:Switch to new keys ... DEBUG:paramiko.transport:Trying SSH agent key d0f5d22e756685a3640d3a24ec18bb6c DEBUG:paramiko.transport:userauth is OK DEBUG:paramiko.transport:Authentication type (publickey) not permitted. DEBUG:paramiko.transport:Allowed methods: [u'password'] DEBUG:paramiko.transport:Trying discovered key d014d32e356785aa628d3aa44cd6b265 in /Users/christian.macnevin/.ssh/id_rsa INFO:paramiko.transport:Disconnect (code 2): Protocol error: expected packet type 50, got 5 Error encountered for cisco_switch: No existing session DEBUG:paramiko.transport:EOF in transport thread None

Done.

私がFalseにparamikoのの 'look_for_keys' を設定示唆いくつかのアドバイスを見てきましたが、どちらかが、その間違って持って、この比較的単純な例で例えば

、それが助けにならなかった。数日前にはうまくいきましたので、何か他のものがあると思われます。

関連:

FAB --version ファブリック1.12.0 Paramiko 1.17.2

パイソン--version パイソン2.7.12

+0

ファブファイルまたはコマンドで指定されたホストが見つかりませんでした。 'fab --host = <ホスト名> test_ver'を試してみてください。また、 '@ task'デコレータでタスクをデコレートするようにしてください。 – 2ps

+0

こんにちは、応答ありがとうございます。このテストではできることはすべて取り除いたので、コマンドラインでホストを指定します。 @taskを追加しますが、最初に問題が発生したファイルには影響していません。 –

答えて

0

端において、より多くのアンパイルと再インストールして再起動すると、このトリックが実行されました。要するに、paramikoは状態が悪く、システムの基本的なトラブルシューティングが行われていたようです。助けてくれてありがとう!

関連する問題