一、安装软件pip
- yum -y install epel-release
- yum install python-pip
- pip install --upgrade pip
二、安装paramiko模块
paramiko是用python语言写的一个模块,遵循SSH2协议,支持以加密和认证的方式,进行远程服务器的连接。
由于使用的是python这样的能够跨平台运行的语言,所以所有python支持的平台,
如Linux, Solaris, BSD, MacOS X, Windows等,paramiko都可以支持,因此,如果需要使用SSH从一个平台连接到另外一个平台,
进行一系列的操作时,比如:批量执行命令,批量上传文件等操作,paramiko是最佳工具之一。
1、yum安装默认的python版本为2.7.5
2、安装easy_install 工具
wget http://peak.telecommunity.com/dist/ez_setup.py
python ez_setup.py
3、安装paramiko模块
easy_install paramiko
[root@test1 ~]# easy_install paramiko
Installed /usr/lib/python2.6/site-packages/pycrypto-2.6.1-py2.6-linux-x86_64.egg
Finished processing dependencies for paramiko
[root@test1 ~]# python
Python 2.7.5 (default, Aug 16 2013, 07:56:41)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import paramiko
/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 should rebuild using libgmp >= 5 to avoid timing attack vulnerability.dir(paramiko)
['AUTH_FAILED', 'AUTH_PARTIALLY_SUCCESSFUL', 'AUTH_SUCCESSFUL', 'Agent', 'AgentKey', 'AuthHandler', 'AuthenticationException', 'AutoAddPolicy', 'BadAuthenticationType', 'BadHostKeyException', 'BaseSFTP', 'BufferedFile', 'Channel', 'ChannelException', 'ChannelFile', 'DSSKey', 'ECDSAKey', 'GSSAuth', 'GSS_AUTH_AVAILABLE', 'HostKeys', 'InteractiveQuery', 'Message', 'MissingHostKeyPolicy', 'OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED', 'OPEN_FAILED_CONNECT_FAILED', 'OPEN_FAILED_RESOURCE_SHORTAGE', 'OPEN_FAILED_UNKNOWN_CHANNEL_TYPE', 'OPEN_SUCCEEDED', 'PKey', 'Packetizer', 'PasswordRequiredException', 'ProxyCommand', 'ProxyCommandFailure', 'RSAKey', 'RejectPolicy', 'SFTP', 'SFTPAttributes', 'SFTPClient', 'SFTPError', 'SFTPFile', 'SFTPHandle', 'SFTPServer', 'SFTPServerInterface', 'SFTP_BAD_MESSAGE', 'SFTP_CONNECTION_LOST', 'SFTP_EOF', 'SFTP_FAILURE', 'SFTP_NO_CONNECTION', 'SFTP_NO_SUCH_FILE', 'SFTP_OK', 'SFTP_OP_UNSUPPORTED', 'SFTP_PERMISSION_DENIED', 'SSHClient', 'SSHConfig', 'SSHException', 'SecurityOptions', 'ServerInterface', 'SubsystemHandler', 'Transport', 'WarningPolicy', 'all', 'author', 'builtins', 'doc', 'file', 'license', 'name', 'package', 'path', 'version', '__version_info__', '_version', 'agent', 'auth_handler', 'ber', 'buffered_pipe', 'channel', 'client', 'common', 'compress', 'config', 'dsskey', 'ecdsakey', 'file', 'hostkeys', 'io_sleep', 'kex_gex', 'kex_group1', 'kex_group14', 'kex_gss', 'message', 'packet', 'pipe', 'pkey', 'primes', 'proxy', 'py3compat', 'resource', 'rsakey', 'server', 'sftp', 'sftp_attr', 'sftp_client', 'sftp_file', 'sftp_handle', 'sftp_server', 'sftp_si', 'ssh_exception', 'ssh_gss', 'sys', 'transport', 'util']
一切正常,至此paramiko模块在Linux上安装完成
参考地址:
利用第三方软件安装http://www.voidcn.com/article/p-zixwaglx-en.html
windows下安装:https://www.cnblogs.com/saneri/p/5715661.html
http://xstarcd.github.io/wiki/Python/Python-Paramiko.html paramiko上传下载远程执行命令