Python远程登录Linux操作系统并执行命令(之一)
最近在写一个类似于Linux系统审查工具的Python脚本,远程登录并执行,要用到paramiko模块/pexpect模块。
介绍一下安装方法:(CentOS7环境下)
1、安装依赖:
yum install python-devel.x86_64
yum install openssl-devel
yum install libffi-devel
2、安装pycrypto:
tar -xzvf pycrypto-2.6.1tar.gz
cd pycrypto-2.6.1
python setup.py install
3、安装paramiko:
tar -xzvf paramiko-2.0.2.tar.gz
cd paramiko-2.0.2
python setup.py install
4、安装pexpect:
tar -zxvf pexpect-2.3.tar.gz
cd pexpect-2.3
python setup.py install
5、错误及应对方法:
######################################################################
1、安装pycrypto
从https://www.dlitz.net/software/pycrypto/下载tar包
tar -xzvf pycrypto-2.6.1tar.gz
cd pycrypto-2.6.1
python setup.py build
#提示缺少Python.h文件的解决办法
#yum install python-devel.x86_64
python setup.py install
2、安装paramiko
从https://pypi.python.org/pypi/paramiko/2.0.2下载tar包
tar -xzvf paramiko-2.0.2.tar.gz
cd paramiko-2.0.2
python setup.py build
#提示错误:error: Installed distribution cffi 0.8.6 conflicts with requirement cffi>=1.4.1
#下载安装cffi :https://pypi.python.org/pypi/cffi/
#tar -xzvf cffi-1.8.2.tar.gz
#cd cffi_1.8.2
#python setup.py build
#提示错误:fatal error: ffi.h: No such file or directory
#安装:yum install libffi-devel
#python setup.py install
#cd ..
python setup.py install
#提示错误:fatal error: openssl/opensslv.h: No such file or directory
#yum install openssl-devel
1、安装pycrypto
从https://www.dlitz.net/software/pycrypto/下载tar包
tar -xzvf pycrypto-2.6.1tar.gz
cd pycrypto-2.6.1
python setup.py build
#提示缺少Python.h文件的解决办法
#yum install python-devel.x86_64
python setup.py install
2、安装paramiko
从https://pypi.python.org/pypi/paramiko/2.0.2下载tar包
tar -xzvf paramiko-2.0.2.tar.gz
cd paramiko-2.0.2
python setup.py build
#提示错误:error: Installed distribution cffi 0.8.6 conflicts with requirement cffi>=1.4.1
#下载安装cffi :https://pypi.python.org/pypi/cffi/
#tar -xzvf cffi-1.8.2.tar.gz
#cd cffi_1.8.2
#python setup.py build
#提示错误:fatal error: ffi.h: No such file or directory
#安装:yum install libffi-devel
#python setup.py install
#cd ..
python setup.py install
#提示错误:fatal error: openssl/opensslv.h: No such file or directory
#yum install openssl-devel
python setup.py install
######################################################################
less is beautiful