27

paramiko ライブラリを使用して Cisco ACS デバイスに ssh しようとすると、次のエラーが発生します。問題なく Python で paramiko を使用しました。コマンド ラインからこのボックスに ssh することも、パテを問題なく使用することもできます。デバッグをオンにして、ここに情報をコピーしました。あなたが私を助けることができるかどうか私に知らせてください.

import paramiko
import sys
import socket

try:
    paramiko.common.logging.basicConfig(level=paramiko.common.DEBUG)
    sshConnection = paramiko.SSHClient()
    sshConnection.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    sshConnection.connect('server',username='username',password='password')
except paramiko.BadAuthenticationType:
    sys.stdout.write('Bad Password!\n')     
    sys.exit()
except paramiko.SSHException, sshFail:
    sys.stdout.write('Connection Failed!\n')
    sys.stdout.write('%s\n' % sshFail)
    sys.exit()
except socket.error, socketFail:
    sys.stdout.write('Failed to open socket\n')
    sys.stdout.write('%s\n' % socketFail)
    sys.exit()

そしてデバッグ出力が返されました:

DEBUG:paramiko.transport:starting thread (client mode): 0x14511d0L
INFO:paramiko.transport:Connected (version 2.0, client OpenSSH_5.3)
DEBUG:paramiko.transport:kex algos:['diffie-hellman-group14-sha1'] server key:['ssh-rsa'] client encrypt:['aes256-cbc', 'aes128-cbc', '3des-cbc'] server encrypt:['aes256-cbc', 'aes128-cbc', '3des-cbc'] client mac:['hmac-sha1'] server mac:['hmac-sha1'] client compress:['none', 'zlib@openssh.com'] server compress:['none', 'zlib@openssh.com'] client lang:[''] server lang:[''] kex follows?False
ERROR:paramiko.transport:Exception: Incompatible ssh peer (no acceptable kex algorithm)
ERROR:paramiko.transport:Traceback (most recent call last):
ERROR:paramiko.transport:  File "build\bdist.win32\egg\paramiko\transport.py", line 1546, in run
ERROR:paramiko.transport:    self._handler_table[ptype](self, m)
ERROR:paramiko.transport:  File "build\bdist.win32\egg\paramiko\transport.py", line 1618, in _negotiate_keys
ERROR:paramiko.transport:    self._parse_kex_init(m)
ERROR:paramiko.transport:  File "build\bdist.win32\egg\paramiko\transport.py", line 1731, in _parse_kex_init
ERROR:paramiko.transport:    raise SSHException('Incompatible ssh peer (no acceptable kex algorithm)')
ERROR:paramiko.transport:SSHException: Incompatible ssh peer (no acceptable kex algorithm)
ERROR:paramiko.transport:
Connection Failed!
Incompatible ssh peer (no acceptable kex algorithm)

最新バージョンの pycrypto と paramiko がインストールされていることを確認しました。

4

7 に答える 7

20

サーバー側の Debian 8 と OpenSSH で同様の問題が発生していました。

簡単な修正として、サーバー側で次の Cipher/MACs/KexAlgorithms 設定を行うと、問題が修正されます。

/etc/ssh/sshd_config:

Ciphers aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes128-ctr
MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,hmac-ripemd160,hmac-sha1
KexAlgorithms diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1

ただし...セキュリティの観点からこれらの設定を分析する必要があります。ラボ環境で設定したので、気にしませんでした。

また、Cisco ACS でこの方法で変更できるかどうかもわかりません

于 2015-09-21T08:56:48.127 に答える
18

問題を修正するために paramiko をアップグレードしました。

 sudo pip install paramiko --upgrade

私のパラミコの更新バージョンは次のとおりです。

paramiko==2.0.2

于 2016-09-08T21:57:34.790 に答える
1

私にとっては、paramiko のバージョンをアップグレードしたところ、問題は解決しました。具体的には、最初に Ubuntu 14.04 python-paramiko パッケージを介して paramiko をインストールし、pip (1.10 -> 1.16) を使用して最新のものに置き換えました。

于 2016-04-27T04:34:54.620 に答える
0

これはOPの状況には役立たないかもしれませんが、うまくいけば、同じエラーで他の誰かを助けるかもしれません.

あるスクリプトはシステムに SSH で問題なく接続できるが、別の同様のスクリプトは同じエラーで失敗するという状況に遭遇しました。

paramiko.SSHException: Incompatible ssh peer (no acceptable kex algorithm)

エラー。

状況は、スクリプトの上部にあるシバン行であることが判明しました。

#!/usr/bin/python

失敗しますが、

#!/usr/bin/env python

成功するでしょう。

システムでvirtualenvを使用しているため、失敗した/usr/bin/pythonバージョンはシステムにインストールされた古いParamikoバージョンを使用していましたが、/usr/bin/env pythonバージョンはvirtualenvで新しいParamikoインストールを使用していました。

于 2016-02-11T17:26:26.580 に答える