1.先下载:pycrypto-2.6.tar.gz paramiko-1.7.5.zip gmp-5.1.2.tar.bz2
2.安装pycrypto
wget http://ftp.dlitz.net/pub/dlitz/crypto/pycrypto/pycrypto-2.6.tar.gz
tar -xf pycrypto-2.6.tar.gz
cd pycrypto-2.6/
python setup.py build && python setup.py install
3.安装 paramiko
wget https://pypi.python.org/packages/2b/27/b64860e7b208ff1dd36fe208d07bca1f9637a11fe733e2f2ceea587c3f75/paramiko-1.7.5.zip
unzip paramiko-1.7.5.zip
cd paramiko-1.7.5
python setup.py build && python setup.py install
测试:
python>> import paramiko
***注意 python2.7,Centos7以上不会出现以下错误,已经测试过。***
报错
/usr/lib64/python2.4/site-packages/Crypto/Util/number.py:57: PowmInsecureWarning: Not using mpz_powm_sec. You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.
_warn("Not using mpz_powm_sec. You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.", PowmInsecureWarning)
/usr/lib64/python2.4/site-packages/Crypto/Util/randpool.py:40: RandomPool_DeprecationWarning: This application uses RandomPool, which is BROKEN in older releases. See http://www.pycrypto.org/randpool-broken
RandomPool_DeprecationWarning)
打开该文件,用#注释掉这两行39和40行代码:
vim /usr/lib64/python2.4/site-packages/Crypto/Util/randpool.py
修改后再次运行报错:
>>> import paramiko
/usr/lib64/python2.4/site-packages/Crypto/Util/number.py:57: PowmInsecureWarning: Not using mpz_powm_sec. You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.
_warn("Not using mpz_powm_sec. You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.", PowmInsecureWarning)
这个报错是gpm版本太低了,
rpm -qa|grep gmp
gmp-devel-4.1.4-10.el5
gmp-4.1.4-10.el5
gmp-devel-4.1.4-10.el5
gmp-4.1.4-10.el5
删除
yum remove gmp*
再次安装下载gmp5
wget http://ftp.gnu.org/gnu/gmp/gmp-5.1.2.tar.bz2
tar jxf gmp-5.1.2.tar.bz2
cd gmp-5.1.2
./configure && make && make install
echo "/usr/local/lib" >> /etc/ld.so.conf
ldconfig
然后再次运行:
[root@tcas302 awpy]# python
Python 2.4.3 (#1, Oct 23 2012, 22:02:41)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import paramiko
会报错
Traceback (most recent call last):
File "test.py", line 3, in ?
import paramiko
ImportError: No module named paramiko
紧接着重新安装下paramiko即可
cd paramiko-1.7.5
python setup.py build && python setup.py install
再次执行就好了
[root@tcas302 awpy]# python
Python 2.4.3 (#1, Oct 23 2012, 22:02:41)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import paramiko