What is the use of the Paramiko module?
Paramiko is a module written in Python that follows the SSH2 protocol and supports the connection of remote servers in an encrypted and authenticated manner. With the ability to run Cross-platform languages like Python, all of the python-supported platforms, such as Linux, Solaris, BSD, MacOS X, Windows, and so on, can be supported by Paramiko, so Paramiko is one of the best tools if you need to use SSH to connect from one platform to another and perform a series of operations, such as executing commands in bulk, uploading files in bulk, and so on.
The current new version, the official website here:
Https://github.com/paramiko/paramiko
Old version here:
Http://www.lag.net/paramiko/legacy.html
The following preparations are required to install the new version of the Paramiko module:
1.python2.5+ version (Linux, Unix, Windows can), install Python2.7 directly here
Download Address: http://www.python.org
2.PyCrypto 2.1+ Module (Pycrypto is a cryptographic toolkit written using Python)
Download Address: https://www.dlitz.net/software/pycrypto/
3.easy_install Tool (a tool for the Python installation module, like Yum, can automatically resolve dependencies)
Download Address: http://peak.telecommunity.com/dist/ez_setup.py
If we feel that installing Paramiko is still a bit of a problem, it would be worthwhile to use the Paramiko to provide convenience.
Second, install Paramiko on Linux (take CentOS 5.8 32-bit as an example)
1. View the Python version to meet the requirements
1 [root@server1 ~]# python-v
2 python 2.4.3
3 [Root@server1 ~]#
This command is also on Windows, note that capital V
is version 2.4.3 and needs to be upgraded
2. Download and install python2.7
1 [root@server2 ~]# wget http://www.python.org/ftp/python/2.7.5/Python-2.7.5.tar.bz2
2 [root@server2 ~]# tar jxf python-2.7.5.tar.bz2
3 [root@server2 ~]# CD Python-2.7.5
4 [root@server2 python-2.7.5]#./configure--prefix=/ usr/local/python2.7
5 [root@server2 python-2.7.5]# make && make install
6 [Root@server2 python-2.7.5]# echo "Path=/usr/local/python2.7/bin: $PATH" >>/etc/profile
7 [root@server2 python-2.7.5]# source/etc/ Profile
8 [root@server2 python-2.7.5]# python-v
9 python 2.7.5
[root@server2 python-2.7.5]# python
One Python 2.7.5 (default, Aug 2013, 07:56:41)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2
Type "h ELP "," copyright "," credits "or" license "for the more information.
>>>
3. Install Easy_install Tools
1 [root@server2 ~]# wget http://peak.telecommunity.com/dist/ez_setup.py
2 [root@server2 ~]# python ez_setup.py
3 Downloading Http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg
4 processing Setuptools-0.6c11-py2.7.egg
5 Copying Setuptools-0.6c11-py2.7.egg to/usr/local/python2.7/lib/python2.7/ Site-packages
6 Adding setuptools 0.6c11 to easy-install.pth file
7 installing Easy_install script to/usr/local/ Python2.7/bin
8 Installing easy_install-2.7 script To/usr/local/python2.7/bin
9 installed/usr/local/ Python2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg
processing dependencies for setuptools== 0.6C11
finished processing dependencies for SETUPTOOLS==0.6C11
You can install the Easy_install tool just by executing the above command.
4. Install Paramiko module
You can install the Paramiko module using the following command
1 [root@server2 ~]# easy_install Paramiko
Go to Python import Paramiko try it.
1 [root@server2 ~]# python
2 python 2.7.5 (default, Aug 2013, 07:56:41)
3 [GCC 4.1.2 20080704 (Red Hat 4.1.2-52 ] on linux2
4 Type ' help ', ' copyright ', ' credits ' or ' license ' for the more information.
5 >>> Import Paramiko
6/usr/local/python2.7/lib/python2.7/site-packages/ Pycrypto-2.6-py2.7-linux-i686.egg/crypto/util/number.py:57:powminsecurewarning:not using Mpz_powm_sec. You are should rebuild using LIBGMP >= 5 to avoid timing attack.
7 >>>
Import module, if encountered above problems, may be due to the low GMP version of the resulting, GMP is what, Reader network interpretation:
GMP is a free library for arbitrary precision arithmetic, operating on signed integers, rational numbers, and floating poi NT numbers.
It seems to be related to precision.
You can resolve it in the following ways:
Uninstall the lower version first
1 Root@server2 ~]# Rpm-qa | grep GMP
2 gmp-devel-4.1.4-10.el5
3 gmp-4.1.4-10.el5
4 [root@server2 ~]# rpm-e gmp-devel-4.1.4-10.el5.i386
5 [root@server2 ~]# rpm-e gcc-gfortran-4.1.2-52.el5.i386
6 [root@server2 ~]# RPM- e gmp-4.1.4-10.el5
7 [root@server2 ~]# ldconfig
8 [Root@server2 ~]#
Then install the high version of GMP
1 [root@server2 ~]# wget http://ftp.gnu.org/gnu/gmp/gmp-5.1.2.tar.bz2
2 [root@server2 ~]# tar jxf gmp-5.1.2.tar.bz2
3 [root@server2 ~]# CD gmp-5.1.2
4 [root@server2 gmp-5.1.2]#./configure && make && make install< c10/>5 [Root@server2 gmp-5.1.2]# echo "/usr/local/lib" >>/etc/ld.so.conf
6 [Root@server2 gmp-5.1.2]# Ldconfig
Try importing the Paramiko module again: