Меню Рубрики

Paramiko python 3 windows

InstallingВ¶

These instructions cover Paramiko 2.0 and above. If you’re looking to install Paramiko 1.x, see Installing (1.x) . However, the 1.x line relies on insecure dependencies so upgrading is strongly encouraged.

Paramiko itselfВ¶

The recommended way to get Paramiko is to install the latest stable release via pip:

We currently support Python 2.7, 3.4+, and PyPy. Users on Python 2.6 or older (or 3.3 or older) are urged to upgrade.

Paramiko has only a few direct dependencies:

  • The big one, with its own sub-dependencies, is Cryptography; see its specific note below for more details;
  • bcrypt, for Ed25519 key support;
  • pynacl, also for Ed25519 key support.

There are also a number of optional dependencies you may install using setuptools ‘extras’:

If you want all optional dependencies at once, use paramiko[all] .

For Match exec config support, use paramiko[invoke] (which installs Invoke).

For GSS-API / SSPI support, use paramiko[gssapi] , though also see the below subsection on it for details.

paramiko[ed25519] references the dependencies for Ed25519 key support.

  • As of Paramiko 2.x this doesn’t technically do anything, as those dependencies are core installation requirements.
  • However, you should use this for forwards compatibility; 3.0 will drop those dependencies from core, leaving them purely optional.

Release linesВ¶

Users desiring stability may wish to pin themselves to a specific release line once they first start using Paramiko; to assist in this, we guarantee bugfixes for the last 2-3 releases including the latest stable one.

This typically spans major & minor versions, so even if e.g. 3.1 is the latest stable release, it’s likely that bugfixes will occasionally come out for the latest 2.x and perhaps even 1.x releases, as well as for 3.0. New feature releases for previous major-version lines are less likely but not unheard of.

If you’re unsure which version to install:

  • Completely new users should always default to the latest stable release (as above, whatever is newest / whatever shows up with pip install paramiko .)
  • Users upgrading from a much older version (e.g. 1.7.x through 1.10.x) should probably get the oldest actively supported line (check the Changelog for recent releases).
  • Everybody else is hopefully already “on” a given version and can carefully upgrade to whichever version they care to, when their release line stops being supported.

CryptographyВ¶

Cryptography provides the low-level (C-based) encryption algorithms we need to implement the SSH protocol. It has detailed installation instructions (and an FAQ) which you should read carefully.

In general, you’ll need one of the following setups:

On Windows or Mac OS X, provided your pip is modern (8.x+): nothing else is required. pip will install statically compiled binary archives of Cryptography & its dependencies.

On Linux, or on other platforms with older versions of pip : you’ll need a C build toolchain, plus development headers for Python, OpenSSL and libffi . Again, see Cryptography’s install docs; these requirements may occasionally change.

If you go this route, note that OpenSSL 1.0.1 or newer is effectively required. Cryptography 1.3 and older technically allow OpenSSL 0.9.8, but 1.4 and newer — which Paramiko will gladly install or upgrade, if you e.g. pip install -U — drop that support.

Optional dependencies for GSS-API / SSPI / KerberosВ¶

In order to use GSS-API/Kerberos & related functionality, additional dependencies are required. It hopefully goes without saying but all platforms need a working installation of GSS-API itself, e.g. Heimdal.

If you use Microsoft SSPI for kerberos authentication and credential delegation, make sure that the target host is trusted for delegation in the active directory configuration. For details see: http://technet.microsoft.com/en-us/library/cc738491%28v=ws.10%29.aspx

The gssapi “extra” install flavor¶

If you’re installing via pip (recommended), you should be able to get the optional Python package requirements by changing your installation to refer to paramiko[gssapi] (from simply paramiko ), e.g.:

(Or update your requirements.txt , or etc.)

Manual dependency installationВ¶

If you’re not using pip or your pip is too old to support the “extras” functionality, the optional dependencies are as follows:

All platforms need pyasn1 0.1.7 or later.

Unix needs: gssapi 1.4.1 or better.

  • An alternative is the python-gssapi library ( 0.6.1 or above), though it is no longer maintained upstream, and Paramiko’s support for its API may eventually become deprecated.

Windows needs pywin32 2.1.8 or better.

Paramiko

A Python implementation of SSHv2.

Navigation

Quick search

Donate/support

Professionally-supported Paramiko is available with the Tidelift Subscription.

Источник

Модуль paramiko¶

Paramiko — это реализация протокола SSHv2 на Python. Paramiko предоставляет функциональность клиента и сервера. В книге рассматривается только функциональность клиента.

Так как Paramiko не входит в стандартную библиотеку модулей Python, его нужно установить:

Подключение выполняется таким образом: сначала создается клиент и выполняются настройки клиента, затем выполняется подключение и получение интерактивной сессии:

SSHClient это класс, который представляет соединение к SSH-серверу. Он выполняет аутентификацию клиента. Следующая настройка set_missing_host_key_policy не является обязательной, она указывает какую политику использовать, когда выполнятся подключение к серверу, ключ которого неизвестен. Политика paramiko.AutoAddPolicy() автоматически добавляет новое имя хоста и ключ в локальный объект HostKeys.

Метод connect выполняет подключение к SSH-серверу и аутентифицирует подключение. Параметры:

  • look_for_keys — по умолчанию paramiko выполняет аутентификацию по ключам. Чтобы отключить это, надо поставить флаг в False
  • allow_agent — paramiko может подключаться к локальному SSH агенту ОС. Это нужно при работе с ключами, а так как в данном случае аутентификация выполняется по логину/паролю, это нужно отключить.

После выполнения предыдущей команды уже есть подключение к серверу. Метод invoke_shell позволяет установить интерактивную сессию SSH с сервером.

Метод send¶

Метод send — отправляет указанную строку в сессию и возвращает количество отправленных байт или ноль если сессия закрыта и не удалось отправить команду:

В коде после send надо будет ставить time.sleep, особенно между send и recv. Так как это интерактивная сессия и команды набираются медленно, все работает и без пауз.

Метод recv¶

Метод recv получает данные из сессии. В скобках указывается максимальное значение в байтах, которое нужно получить. Этот метод возвращает считанную строку.

Источник

Установить парамико на Windows

Все перечисленные методы просто не работают.

Авторы имеют разные среды с разными компонентами / библиотеками. Или, может быть, они не проверяют свои решения, прежде чем отправлять ответ:)

Я удалил все версии и библиотеки Python со своей машины (Windows 8 x64) и попытался установить Python и Paramiko с нуля.

Способ № 1 (СБОЙ)

  1. Установите python-2.7.3.amd64.msi
  2. Установите pycrypto-2.6.win-amd64-py2.7.exe
  3. Загрузите https://github.com/paramiko/paramiko/archive/master.zip, распакуйте его.
  4. Запустите setup.py install
  5. Зайдите в IDLE, запустите импорт paramiko.

Способ № 2 (СБОЙ)

  1. Установите python-2.7.3.amd64.msi
  2. Установите setuptools-1.4.2.win-amd64-py2.7.exe
  3. Установите pip-1.4.1.win-amd64-py2.7.exe
  4. pip install paramiko
  5. Зайдите в IDLE, запустите импорт paramiko.

Метод № 3 (УСПЕХ)

  1. Установите python-2.7.3.amd64.msi
  2. Установите pycrypto-2.6.win-amd64-py2.7.exe
  3. Установите setuptools-1.4.2.win-amd64-py2.7.exe
  4. Установите pip-1.4.1.win-amd64-py2.7.exe
  5. Запустите pip install ecdsa
  6. Загрузите и извлеките https://github.com/paramiko/paramiko/archive/master.zip
  7. Запустите setup.py install
  8. Откройте IDLE, запустите импорт paramiko

Результат: нет ошибок

Пожалуйста, помогите мне найти пошаговый алгоритм установки Python и Paramiko на чистой машине Windows 8. Thanx.

UPD: решение найдено.

5 ответов

Для установки paramiko необходим компилятор Visual Basic.

Откройте каталог paramiko и запустите python setup.py install . И это будет загружать зависимости из Интернета; особенно pycrypto и установка будет успешной.

Вы скучаете по pycrypto зависимость. pip это самый простой способ:

Кроме того, вы можете установить из источника, с помощью:

Для пользователей Windows:

  1. Установите Python 2.7.11
  2. Загрузите и установите pycrypto win-amd64-py2.7.exe

Теперь откройте командную строку. Если вы установили Python в следующем месте:

c: \ Python27, затем измените каталог и перейдите в каталог Scripts.

Теперь введите следующую команду:

pip install paramiko

Вот и все, вы успешно установили Paramiko.

Для первой последовательности вам нужно установить ‘ecdsa’ с pip, потому что компиляция paramiko не разрешает автоматически ее зависимости (как ваше рабочее решение)

Второй сбой, как уже говорилось, потому что вы не установили pycrypto перед запуском pip install paramiko , Я бы порекомендовал использовать эту опцию вместо установки из исходного кода, чтобы облегчить путь обновления с помощью pip. Также pip проще всего установить с помощью отдельного сценария установки: http://pip.readthedocs.org/en/latest/installing.html

Также я столкнулся со следующими ошибками:

C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe / c / nologo / Ox / MD / W3 / GS- / DNDEBUG -IC: \ Python27-x86 \ include -IC: \ Python27 -x86 \ PC /Tcbuild\temp.win32-2.7\Release_openssl.c /Fobuild\temp.win32-2.7\Release\build\temp.win32-2.7\Release_openssl.obj

build \ temp.win32-2.7 \ Release_openssl.c (423): фатальная ошибка C1083: Невозможно открыть включаемый файл: ‘openssl/opensslv.h’: такого файла или каталога нет

ошибка: команда «C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe» завершилась неудачно с состоянием выхода 2

пропустил этот файл: ‘openssl/opensslv.h’

это произойдет потому, что при установке пакетов paramiko / cryptography / pyOpenSSL им всем требовался дистрибутив OpenSSL-Win32 с *.lib и файлами заголовков, такими как: openssl \ opensslv.h

Итак, после установки соответствующего OpenSSL приложения. версия, взята отсюда: http://code.x2go.org/releases/binary-win32/3rd-party/Win32OpenSSL/

и скопировал все заголовки из C: \ OpenSSL-Win32 \ include \ openssl *. * в C: \ Pyhton27 \ inclide *. *

и скопировал все библиотеки из C: \ OpenSSL-win32 \ lib в C: \ Python27 \ Lib *. *

Пакет paramiko был успешно установлен.! Надеюсь это кому-нибудь пригодится.:) удачи:)

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *

  • Parallels workstation для windows 10
  • Parallels transporter agent для windows
  • Parallels tools для windows 7
  • Parallels rdp client windows
  • Parallels desktop удаление windows