转自:http://www.cnblogs.com/taiguyiba/p/6051022.html
首先安装依赖库:
yum -y install gcc
1 安装 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
测试,注意大小写
python>> import Crypto
2 安装 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
报错
/usr/lib64/python2.6/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)
打开该文件,掉这两行代码:
vim /usr/lib64/python2.6/site-packages/Crypto/Util/randpool.py
再次验证则通过
python>> import paramiko 远程登录
import paramiko #绑定客户端 ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect("10.10.10.62",22,"root", "888888") stdin, stdout, stderr = ssh.exec_command("/sbin/ifconfig") print stdout.readlines() ssh.close()
时间: 2024-10-13 10:16:10