0

When I try to use the paramiko module it returns an error. I have tried to install cliff/python cliff module but that hasn't solved the problem. I've also followed the recommendations here: Python pip install request[security] have error without success. Does any one know how to do this? Thanks.

import paramiko
paramiko.util.log_to_file("filename.log")
def connect():
    client=paramiko.SSHClient()
    client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    client.connect('192.168.0.100',username='XXX',password='XXX')
    chan = client.get_transport().open_session()
    chan.send("Hello")
    print chan.recv(1024)
connect()

Here is the error log:

DEB [20160703-06:53:33.249] thr=1   paramiko.transport: starting thread (client mode): 0xb53dd250L
DEB [20160703-06:53:33.249] thr=1   paramiko.transport: Local version/idstring: SSH-2.0-paramiko_2.0.1
DEB [20160703-06:53:33.305] thr=1   paramiko.transport: Remote version/idstring: SSH-2.0-paramiko_1.15.3
INF [20160703-06:53:33.305] thr=1   paramiko.transport: Connected (version 2.0, client paramiko_1.15.3)
DEB [20160703-06:53:33.306] thr=1   paramiko.transport: kex algos:[u'diffie-hellman-group14-sha1', u'diffie-hellman-group-exchange-sha1', u'diffie-hellman-group1-sha1'] server key:[u'ssh-rsa'] client encrypt:[u'aes128-ctr', u'aes256-ctr', u'aes128-cbc', u'blowfish-cbc', u'aes256-cbc', u'3des-cbc', u'arcfour128', u'arcfour256'] server encrypt:[u'aes128-ctr', u'aes256-ctr', u'aes128-cbc', u'blowfish-cbc', u'aes256-cbc', u'3des-cbc', u'arcfour128', u'arcfour256'] client mac:[u'hmac-sha1', u'hmac-md5', u'hmac-sha1-96', u'hmac-md5-96'] server mac:[u'hmac-sha1', u'hmac-md5', u'hmac-sha1-96', u'hmac-md5-96'] client compress:[u'none'] server compress:[u'none'] client lang:[u''] server lang:[u''] kex follows?False
DEB [20160703-06:53:33.306] thr=1   paramiko.transport: Kex agreed: diffie-hellman-group1-sha1
DEB [20160703-06:53:33.306] thr=1   paramiko.transport: Cipher agreed: aes128-ctr
DEB [20160703-06:53:33.306] thr=1   paramiko.transport: MAC agreed: hmac-md5
DEB [20160703-06:53:33.306] thr=1   paramiko.transport: Compression agreed: none
ERR [20160703-06:53:33.350] thr=1   paramiko.transport: Unknown exception: No     module named _cffi_backend
ERR [20160703-06:53:33.353] thr=1   paramiko.transport: Traceback (most recent call last):
ERR [20160703-06:53:33.353] thr=1   paramiko.transport:   File "/usr/local/lib/python2.7/dist-packages/paramiko/transport.py", line 1772, in run
ERR [20160703-06:53:33.353] thr=1   paramiko.transport:     self.kex_engine.parse_next(ptype, m)
ERR [20160703-06:53:33.353] thr=1   paramiko.transport:   File "/usr/local/lib/python2.7/dist-packages/paramiko/kex_group1.py", line 75, in parse_next
ERR [20160703-06:53:33.353] thr=1   paramiko.transport:     return self._parse_kexdh_reply(m)
ERR [20160703-06:53:33.353] thr=1   paramiko.transport:   File "/usr/local/lib/python2.7/dist-packages/paramiko/kex_group1.py", line 111, in _parse_kexdh_reply
ERR [20160703-06:53:33.353] thr=1   paramiko.transport:     self.transport._verify_key(host_key, sig)
ERR [20160703-06:53:33.353] thr=1   paramiko.transport:   File "/usr/local/lib/python2.7/dist-packages/paramiko/transport.py", line 1617, in _verify_key
ERR [20160703-06:53:33.353] thr=1   paramiko.transport:     key = self._key_info[self.host_key_type](Message(host_key))
ERR [20160703-06:53:33.353] thr=1   paramiko.transport:   File "/usr/local/lib/python2.7/dist-packages/paramiko/rsakey.py", line 58, in __init__
ERR [20160703-06:53:33.353] thr=1   paramiko.transport:     ).public_key(default_backend())
ERR [20160703-06:53:33.353] thr=1   paramiko.transport:   File "/usr/local/lib/python2.7/dist-packages/cryptography/hazmat/backends/__init__.py", line 35, in default_backend
ERR [20160703-06:53:33.353] thr=1   paramiko.transport:     _default_backend = MultiBackend(_available_backends())
ERR [20160703-06:53:33.353] thr=1   paramiko.transport:   File "/usr/local/lib/python2.7/dist-packages/cryptography/hazmat/backends/__init__.py", line 22, in _available_backends
ERR [20160703-06:53:33.353] thr=1   paramiko.transport:     "cryptography.backends"
ERR [20160703-06:53:33.353] thr=1   paramiko.transport:   File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2235, in     resolve
ERR [20160703-06:53:33.353] thr=1   paramiko.transport:     module = __import__(self.module_name, fromlist=['__name__'], level=0)
ERR [20160703-06:53:33.354] thr=1   paramiko.transport:   File "/usr/local/lib/python2.7/dist-packages/cryptography/hazmat/backends/openssl/__init__.py", line 7, in <module>
ERR [20160703-06:53:33.354] thr=1   paramiko.transport:     from cryptography.hazmat.backends.openssl.backend import backend
ERR [20160703-06:53:33.354] thr=1   paramiko.transport:   File "/usr/local/lib/python2.7/dist-packages/cryptography/hazmat/backends/openssl/backend.py", line 15, in <module>
ERR [20160703-06:53:33.354] thr=1   paramiko.transport:     from cryptography     import utils, x509
ERR [20160703-06:53:33.354] thr=1   paramiko.transport:   File "/usr/local/lib/python2.7/dist-packages/cryptography/x509/__init__.py", line 7, in <module>
ERR [20160703-06:53:33.354] thr=1   paramiko.transport:     from cryptography.x509.base import (
ERR [20160703-06:53:33.354] thr=1   paramiko.transport:   File "/usr/local/lib/python2.7/dist-packages/cryptography/x509/base.py", line 15, in <module>
ERR [20160703-06:53:33.354] thr=1   paramiko.transport:     from cryptography.x509.extensions import Extension, ExtensionType
ERR [20160703-06:53:33.354] thr=1   paramiko.transport:   File "/usr/local/lib/python2.7/dist-packages/cryptography/x509/extensions.py", line 19, in <module>
ERR [20160703-06:53:33.354] thr=1   paramiko.transport:     from cryptography.hazmat.primitives import constant_time, serialization
ERR [20160703-06:53:33.354] thr=1   paramiko.transport:   File "/usr/local/lib/python2.7/dist-packages/cryptography/hazmat/primitives/constant_time.py", line 9, in <module>
ERR [20160703-06:53:33.358] thr=1   paramiko.transport:     from cryptography.hazmat.bindings._constant_time import lib
ERR [20160703-06:53:33.358] thr=1   paramiko.transport: ImportError: No     module named _cffi_backend
ERR [20160703-06:53:33.358] thr=1   paramiko.transport:
Community
  • 1
  • 1
user3404608
  • 157
  • 1
  • 2
  • 14
  • Install pycharm community edition. this is python ide from Jetbrains. this itself will handle installing packages. In your source code, if you write, 'import paramiko' and if this module is not present, you can trigger installin g the package from the editor itself. it's so cool to code from pycharm – a3.14_Infinity Jul 03 '16 at 05:53
  • Thanks for reply , i have try to install module by pycharm but can not install success . – user3404608 Jul 03 '16 at 06:28
  • hi, for me, with python 3.5.2, it seems to work fine. Probably, if you are not tied to the version, 1) you could install python 3.5.2. 2) from settings -> project interpreter -> set the interpreter to version 3.5.2. 3) go to editor and type: import paramiko. 4) it might report error 5) press alt+enter 6) select install package paramiko – a3.14_Infinity Jul 04 '16 at 03:25

0 Answers0