Download the Software installation package and install it, the official website https://pypi.python.org/pypi/paramiko/[[emailprotected]~]#wgethttps://pypi.python.org/packages/source/p/paramiko/ Paramiko-1.14.0.tar.gz#md5=e26324fd398af68ad506fe98853835c3[[emailprotected]~]#tarxf paramiko-1.14.0.tar.gz[[emailprotected]~]
Using python to remotely log on to the host and execute commands or upload and download files through sftp, there is a good module paramiko module to demonstrate these functions, which is very convenient to use, you can learn. I wrote several small programs to illustrate how to use this module.
1: connect to a remote linux host and execute the command
#!/usr/bin/envpython
importparamiko
hostname='192.168.0.102'
username='root'
password='a
Ready to start Learning: Paramiko module, found this module is very difficult to install
Engaged for a half day, Win10 64 Pytyon 3.6 of the Paramiko module is not on, on-line constantly looking for information, but no use, no use AH
Can't, use virtual machine to make a centos7, install, fail, install again, fail again, surf the net to find information, finally fix, share experience, lest everybody step on
In the process of installing the software, we must find the correct method of installation, before looking for a lot of solutions to the problem, but found that most of the methods are wrong, wasting time, the problem is difficult to solve.Article for reference http://www.cnblogs.com/saneri/p/5715661.html1. First download pycrypto for Python Select the corresponding pycrypto based on your Python version and download the default installation.Address: Http://www.voidspace.org.uk/python/modules.sht
Today, I took the time to change my mind and found that the current ST project can only run in linux, but the Department does not use ST to ensure code quality. Therefore, if you want to use it in windows, you first need to execute commands remotely on windows and collect execution results, automatically upload scripts, and automatically download logs. This requires the use of the ssh service, so I learned how to use the ssh function of python in windows.OpenSSH is required to use SSH in Python,
Python uses paramiko to remotely copy objects,
This example describes how to use paramiko to remotely copy objects in python. We will share this with you for your reference. The details are as follows:
First, install the paramiko Library (which implements the SSH2 Security Protocol). In ubuntu, you can directly install it through the source:
Sudo apt-get insta
1. CentOS 7 installation Python3.5CentOS7 installed python2.7.5 By default, you need to install it manually with Python3. Be careful not to delete Python2. 1.1 Download Python3 Source Packagewget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz 1.2 installation dependent yum install openssl-devel libxslt-devel-y 1.3 Unzip the source package and compile the installation.TAR-XVF python-3.5.2.tgz ./configure--prefix=/usr/python3.5 make Make install 1.4 add Python3 to
The recent project on cloud platform requires Python to manage all the hosts, and I chose Paramiko. It can be used across platforms, Linux and Windows, and PSSH only supports Linux.1: Installing GCC and Python-develYum Install gcc gcc-c++ python-devel2:paramiko relies on the Pycrypto module to download the Pycrypto installation firstwget http://ftp.dlitz.net/pub/dlitz/crypto/pycrypto/pycrypto-2.6.tar.gzUnz
After installing Paramiko, look at the following example:
The code is as follows:
Import Paramiko
#设置ssh连接的远程主机地址和端口T=paramiko. Transport ((Ip,port))#设置登录名和密码T.connect (Username=username,password=password)#连接成功后打开一个channelChan=t.open_session ()#设置会话超时时间Chan.settimeout (Session_timeout)#打开远程的terminalChan.get_pty ()#激活terminalChan.invoke_shell ()You can then
folder, for example: E:\MinGW. Files with the suffix Lzma are extracted with 7zip.3) Add E:\MinGW\bin to the system environment variable
At this point, the GCC installation on Windows is completeYou can then execute the input gcc execution command under the cmd command.
8. Modify the Python installation file:Assume that the Python installation directory is C:\Python25\Lib\distutilsCreate a new distutils.cfg file under directory C:\Python25\Lib\distutilsContent:Copy the Code code as follows:
[Bu
Fortress Machine-readme:(Database is MySQL)1, if the database does not exist, create a database, user authorization to the database, create a table structure, and initialize some of the data2. If the database exists, skip to the next step3. User Login Fortress machine to verify4, if this bastion machine user exists, verify success, list the bastion machine user all the host group, and the user's host groups can use the number of hosts.5, users select a host group, you can see the list of availab
Use python paramiko to create a bastion hostBastion host-readme: (the database is mysql) 1. If the database does not exist, create a database, authorize the database user, create a table structure, and initialize some data. 2. If the database exists, go to Step 3. log on to the bastion host for verification. 4. If the bastion host user exists and the verification is successful, all the host groups of the bastion host user will be listed, and the numbe
A: IntroductionParamiko is a module written in the Python language that follows the SSH2 protocol and supports the connection of remote servers in a way that is encrypted and authenticated.Two: Installation1.pycrypto InstallationDownload Link: https://pypi.python.org/pypi/pycryptoPython setup.py BuildPython setup.py Install2.paramiko InstallationDownload Link: https://pypi.python.org/pypi/paramiko/1.15.2Pyt
one folder, for example: E:\MinGW. A file with a suffix name of Lzma, with a 7zip decompression.3) Add E:\MinGW\bin to System environment variables
At this point, the GCC installation on Windows is completeYou can then execute the input gcc execution command under the cmd command.
8. Modify the Python installation file:Suppose the installation directory for Python is C:\Python25\Lib\distutilsCreate a new Distutils.cfg file under the directory C:\Python25\Lib\distutilsContent:
Copy Code
Tags:/usr import and auth except stdin install Linux host1, Paramiko IntroductionParamiko is an SSH remote secure connection based on Python that supports authentication and secret key methods. It can realize the functions of remote command execution, file transfer, intermediate SSH proxy and so on.2. Installing the Paramiko moduleshell>pip install paramiko3. batch modify Linux host password script#!/usr/bi
This example describes how Python uses Paramiko to implement remote copy files. Share to everyone for your reference, as follows:
The first is the installation of the Paramiko library (which implements the SSH2 security protocol), which can be installed directly under Ubuntu via the Source:
sudo apt-get install Python-paramiko
Next is the code for remot
SFTP is an SSH-based file Transfer protocol that is the most common way to transfer files to Linux on Windows (for example, securefx,xftp).Under Python, Paramiko implements SFTP, allowing you to easily implement file transfer functionality in your code.Official website is here: http://www.lag.net/paramiko/You can use Easy_install Paramiko to install.The following
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.