Как установить paramiko на windows python 3

The leading native Python SSHv2 protocol library. Contribute to paramiko/paramiko development by creating an account on GitHub.

Note

These instructions cover Paramiko 2.0 and above. If you’re looking to
install Paramiko 1.x, see :doc:`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:

$ pip install paramiko

We currently support Python 3.6+ only. Users on older interpreter versions
are urged to upgrade.

Paramiko has only a few direct dependencies:

  • The big one, with its own sub-dependencies, is Cryptography; see :ref:`its
    specific note below <cryptography>`
    for more details;
  • bcrypt and pynacl for Ed25519 key support.

There are also a handful 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 and/or ProxyCommand feature support,
    use paramiko[invoke] (which installs Invoke).
  • For GSS-API / SSPI support, use paramiko[gssapi], though also see
    :ref:`the below subsection on it <gssapi>` for details.

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
    :doc:`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.

    Warning

    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.

  • Similarly, Cryptography 3.4 and above require Rust language tooling to
    install from source; once again see Cryptography’s documentation for details
    here, such as their Rust install section and this FAQ entry.

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.

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.:

pip install "paramiko[gssapi]"

(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.

OK. I read installing paramiko on Windows.

All mentioned methods simply do not work.

Authors have different environments with different components/libraries installed. Or may be they don’t test their solutions before posting an answer :)

I removed all python versions and libs from my machine (Windows 8 x64) and tried to install python and paramiko from scratch.

Method number 1 (FAILED)

  1. Install python-2.7.3.amd64.msi
  2. Install pycrypto-2.6.win-amd64-py2.7.exe
  3. Download https://github.com/paramiko/paramiko/archive/master.zip, unpack it.
  4. Run setup.py install
  5. Go to IDLE, run import paramiko.

Result:

Traceback (most recent call last):   File "<pyshell#0>", line 1, in
<module>
  import paramiko   File "C:Python27libsite-packagesparamiko__init__.py", line 65, in
<module>
    from transport import SecurityOptions, Transport   File "C:Python27libsite-packagesparamikotransport.py", line 45, in
<module>
   from paramiko.ecdsakey import ECDSAKey   File "C:Python27libsite-packagesparamikoecdsakey.py", line 24, in
<module>
  from ecdsa import SigningKey, VerifyingKey, der, curves ImportError: No module named ecdsa

Method number 2 (FAILED)

  1. Install python-2.7.3.amd64.msi
  2. Install setuptools-1.4.2.win-amd64-py2.7.exe
  3. Install pip-1.4.1.win-amd64-py2.7.exe
  4. pip install paramiko
  5. Go to IDLE, run import paramiko.

Result:

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import paramiko
  File "C:Python27libsite-packagesparamiko__init__.py", line 64, in <module>
    from transport import SecurityOptions, Transport
  File "C:Python27libsite-packagesparamikotransport.py", line 33, in <module>
    from paramiko import util
  File "C:Python27libsite-packagesparamikoutil.py", line 33, in <module>
    from paramiko.common import *
  File "C:Python27libsite-packagesparamikocommon.py", line 98, in <module>
    from Crypto import Random
ImportError: No module named Crypto

Method number 3 (SUCCESS)

  1. Install python-2.7.3.amd64.msi
  2. Install pycrypto-2.6.win-amd64-py2.7.exe
  3. Install setuptools-1.4.2.win-amd64-py2.7.exe
  4. Install pip-1.4.1.win-amd64-py2.7.exe
  5. Run pip install ecdsa
  6. Download and extract https://github.com/paramiko/paramiko/archive/master.zip
  7. Run setup.py install
  8. Open IDLE, run import paramiko

Result: no errors

Please, help me to find step-by-step algorithm for installing python and paramiko on clean windows 8 machine. Thanx.

UPD: Solution has been found.

Improve Article

Save Article

  • Read
  • Discuss
  • Improve Article

    Save Article

    The high-level python API starts with the creation of a secure connection object. To have more direct control and pass a socket to transport to start remote access. As a client, it’s authenticating using a user credential or private key, and checking the server’s host key. 

    Paramiko is a Python library that makes a connection with a remote device through SSh. Paramiko is using SSH2 as a replacement of SSL to make a secure connection between two devices. It also supports the SFTP client and server model.

    Installation

    On Windows

    To install Paramiko on Windows using pip run bellow command on cmd.

    pip install paramiko

    Output:

    To check the installed paramiko run the following:

    pip list

    Output:

    Install paramiko using .whl file offline. To download .whl file https://pypi.org/project/paramiko/#files

    pip install paramiko-2.7.2-py2.py3-none-any.whl

    Output :

    On Linux

    Python paramiko can be installed on Linux in many ways, using pip is one of them.

    pip install paramiko

    Output :

    To check the installed paramiko:

    pip list --format=json

    Output:

    pip install paramiko

    The Python paramiko library is among the top 100 Python libraries, with more than 26,300,408 downloads. This article will show you everything you need to get this installed in your Python environment.

    • Library Link

    How to Install paramiko on Windows?

    1. Type "cmd" in the search bar and hit Enter to open the command line.
    2. Type “pip install paramiko” (without quotes) in the command line and hit Enter again. This installs paramiko for your default Python installation.
    3. The previous command may not work if you have both Python versions 2 and 3 on your computer. In this case, try "pip3 install paramiko" or “python -m pip install paramiko“.
    4. Wait for the installation to terminate successfully. It is now installed on your Windows machine.

    Here’s how to open the command line on a (German) Windows machine:

    Open CMD in Windows

    First, try the following command to install paramiko on your system:

    pip install paramiko

    Second, if this leads to an error message, try this command to install paramiko on your system:

    pip3 install paramiko

    Third, if both do not work, use the following long-form command:

    python -m pip install paramiko

    The difference between pip and pip3 is that pip3 is an updated version of pip for Python version 3. Depending on what’s first in the PATH variable, pip will refer to your Python 2 or Python 3 installation—and you cannot know which without checking the environment variables. To resolve this uncertainty, you can use pip3, which will always refer to your default Python 3 installation.

    How to Install paramiko on Linux?

    You can install paramiko on Linux in four steps:

    1. Open your Linux terminal or shell
    2. Type “pip install paramiko” (without quotes), hit Enter.
    3. If it doesn’t work, try "pip3 install paramiko" or “python -m pip install paramiko“.
    4. Wait for the installation to terminate successfully.

    The package is now installed on your Linux operating system.

    How to Install paramiko on macOS?

    Similarly, you can install paramiko on macOS in four steps:

    1. Open your macOS terminal.
    2. Type “pip install paramiko” without quotes and hit Enter.
    3. If it doesn’t work, try "pip3 install paramiko" or “python -m pip install paramiko“.
    4. Wait for the installation to terminate successfully.

    The package is now installed on your macOS.

    Given a PyCharm project. How to install the paramiko library in your project within a virtual environment or globally? Here’s a solution that always works:

    • Open File > Settings > Project from the PyCharm menu.
    • Select your current project.
    • Click the Python Interpreter tab within your project tab.
    • Click the small + symbol to add a new library to the project.
    • Now type in the library to be installed, in your example "paramiko" without quotes, and click Install Package.
    • Wait for the installation to terminate and close all pop-ups.

    Here’s the general package installation process as a short animated video—it works analogously for paramiko if you type in “paramiko” in the search field instead:

    Make sure to select only “paramiko” because there may be other packages that are not required but also contain the same term (false positives):

    How to Install paramiko in a Jupyter Notebook?

    To install any package in a Jupyter notebook, you can prefix the !pip install my_package statement with the exclamation mark "!". This works for the paramiko library too:

    !pip install my_package

    This automatically installs the paramiko library when the cell is first executed.

    How to Resolve ModuleNotFoundError: No module named ‘paramiko’?

    Say you try to import the paramiko package into your Python script without installing it first:

    import paramiko
    # ... ModuleNotFoundError: No module named 'paramiko'

    Because you haven’t installed the package, Python raises a ModuleNotFoundError: No module named 'paramiko'.

    To fix the error, install the paramiko library using “pip install paramiko” or “pip3 install paramiko” in your operating system’s shell or terminal first.

    See above for the different ways to install paramiko in your environment.

    Improve Your Python Skills

    If you want to keep improving your Python skills and learn about new and exciting technologies such as Blockchain development, machine learning, and data science, check out the Finxter free email academy with cheat sheets, regular tutorials, and programming puzzles.

    Join us, it’s fun! 🙂

    While working as a researcher in distributed systems, Dr. Christian Mayer found his love for teaching computer science students.

    To help students reach higher levels of Python success, he founded the programming education website Finxter.com. He’s author of the popular programming book Python One-Liners (NoStarch 2020), coauthor of the Coffee Break Python series of self-published books, computer science enthusiast, freelancer, and owner of one of the top 10 largest Python blogs worldwide.

    His passions are writing, reading, and coding. But his greatest passion is to serve aspiring coders through Finxter and help them to boost their skills. You can join his free email academy here.

    Paramiko is a Python library that makes a connection with a remote device through SSh. Paramiko is using SSH2 as a replacement for SSL to make a secure connection between two devices. It also supports the SFTP client and server model.

    Authenticating SSH connection

    To authenticate an SSH connection, we need to set up a private RSA SSH key (not to be confused with OpenSSH). We can generate a key using the following command:

    $ ssh-keygen -t rsa

    This will prompt us to provide a name for our key. Name it whatever you like and generate a public/private RSA key pair. Enter the name by which you wish to save the key.

    i.e., /home/username/.ssh/id_rsa 

    Next, you’ll be prompted to provide a password (feel free to leave this blank).

    Now that we have our key, we need to copy this to our remote host. The easiest way to do this is by using ssh-copy-id:

    $ ssh-copy-id -i ~/.ssh/mykey username@my_remote_host.org

    If you’d like to check which keys you already have, these can be found in your system’s .ssh directory:

     ~/.sshCheck 

    We’re looking for keys that begin with the following header:

    —–BEGIN RSA PRIVATE KEY—–

    —–END RSA PRIVATE KEY—–

    SSH(Secure Shell) is an access credential that is used in the SSH Protocol. In other words, it is a cryptographic network protocol that is used for transferring encrypted data over the network. It allows you to connect to a server, or multiple servers, without having you remember or enter your password for each system that is to log in remotely from one system into another.

    Installing Paramiko

    To install paramiko library, run the subsequent command in the command prompt. paramiko needs cryptography as a dependency module. So run both commands in the command prompt :

    pip install paramiko

    pip install cryptography

    Note: For more information, refer to Install Paramiko on Windows and Linux

    After installation is completed, now we’ll hook up with a remote SSH server using paramiko library. Code snippet for an equivalent is given below:

    Python3

    import paramiko

    ssh = paramiko.SSHClient()

    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

    ssh.connect('1.1.1.2', port=22, username='UserName',

                password='PassWord', timeout=3)

    stdin, stdout, stderr = ssh.exec_command('show ip interface brief')

    Taking this as a base, one can automate the things of login to the remote SSH server, executing commands, and capturing the results, just using one python script.

    By this, you can create an SSH connection to another host from within your application, with this connection you can send your commands to the host and retrieve the output. 

    Given below is a program to depict the same. Here we are printing the username.

    Program:

    Python3

    import paramiko

    output_file = 'paramiko.org'

    def paramiko_GKG(hostname, command):

        print('running')

        try:

            port = '22'

            client = paramiko.SSHClient()

            client.load_system_host_keys()

            client.connect(hostname, port=22, username='geeksForgeeks',

                           password='geeksForgeeks')

            (stdin, stdout, stderr) = client.exec_command(command)

            cmd_output = stdout.read()

            print('log printing: ', command, cmd_output)

            with open(output_file, "w+") as file:

                file.write(str(cmd_output))

            return output_file

        finally:

            client.close()

    paramiko_GKG('10.10.10.1', 'uname')

    Output:

    $ python GFG_paramiko.py
    running
    [log printing: ,'uname','Linuxn']

    So by running our Python file we are getting out a printed statement with uname command and Linux as an output. The same program can be modified for different commands to get information as required.

    Paramiko is a Python library that makes a connection with a remote device through SSh. Paramiko is using SSH2 as a replacement for SSL to make a secure connection between two devices. It also supports the SFTP client and server model.

    Authenticating SSH connection

    To authenticate an SSH connection, we need to set up a private RSA SSH key (not to be confused with OpenSSH). We can generate a key using the following command:

    $ ssh-keygen -t rsa

    This will prompt us to provide a name for our key. Name it whatever you like and generate a public/private RSA key pair. Enter the name by which you wish to save the key.

    i.e., /home/username/.ssh/id_rsa 

    Next, you’ll be prompted to provide a password (feel free to leave this blank).

    Now that we have our key, we need to copy this to our remote host. The easiest way to do this is by using ssh-copy-id:

    $ ssh-copy-id -i ~/.ssh/mykey username@my_remote_host.org

    If you’d like to check which keys you already have, these can be found in your system’s .ssh directory:

     ~/.sshCheck 

    We’re looking for keys that begin with the following header:

    —–BEGIN RSA PRIVATE KEY—–

    —–END RSA PRIVATE KEY—–

    SSH(Secure Shell) is an access credential that is used in the SSH Protocol. In other words, it is a cryptographic network protocol that is used for transferring encrypted data over the network. It allows you to connect to a server, or multiple servers, without having you remember or enter your password for each system that is to log in remotely from one system into another.

    Installing Paramiko

    To install paramiko library, run the subsequent command in the command prompt. paramiko needs cryptography as a dependency module. So run both commands in the command prompt :

    pip install paramiko

    pip install cryptography

    Note: For more information, refer to Install Paramiko on Windows and Linux

    After installation is completed, now we’ll hook up with a remote SSH server using paramiko library. Code snippet for an equivalent is given below:

    Python3

    import paramiko

    ssh = paramiko.SSHClient()

    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

    ssh.connect('1.1.1.2', port=22, username='UserName',

                password='PassWord', timeout=3)

    stdin, stdout, stderr = ssh.exec_command('show ip interface brief')

    Taking this as a base, one can automate the things of login to the remote SSH server, executing commands, and capturing the results, just using one python script.

    By this, you can create an SSH connection to another host from within your application, with this connection you can send your commands to the host and retrieve the output. 

    Given below is a program to depict the same. Here we are printing the username.

    Program:

    Python3

    import paramiko

    output_file = 'paramiko.org'

    def paramiko_GKG(hostname, command):

        print('running')

        try:

            port = '22'

            client = paramiko.SSHClient()

            client.load_system_host_keys()

            client.connect(hostname, port=22, username='geeksForgeeks',

                           password='geeksForgeeks')

            (stdin, stdout, stderr) = client.exec_command(command)

            cmd_output = stdout.read()

            print('log printing: ', command, cmd_output)

            with open(output_file, "w+") as file:

                file.write(str(cmd_output))

            return output_file

        finally:

            client.close()

    paramiko_GKG('10.10.10.1', 'uname')

    Output:

    $ python GFG_paramiko.py
    running
    [log printing: ,'uname','Linuxn']

    So by running our Python file we are getting out a printed statement with uname command and Linux as an output. The same program can be modified for different commands to get information as required.

    Понравилась статья? Поделить с друзьями:
  • Как установить red alert 2 на windows 11
  • Как установить pubg mobile на компьютер windows 10
  • Как установить pandas для python windows через cmd
  • Как установить pandas для pycharm windows
  • Как установить ps remote play на windows 10