Python's Paramiko module

Source: Internet
Author: User

Python Paramiko module

1. Installation

1225./configure #在解压后的python2.7.9 in the directory

1226 make

1227 make Install

1228 cd/usr/local/

1229 ls

1230 CD Bin

1231 ls

1232./python

1233 python

1234 Cd/usr/bin

1235 ls

1236 ll python*

1237 mv./python./python26

Version of 1238 Ln-s/usr/local/bin/python./python #链接为2.7.9

1239./python

1240 Python

1241 Pip

1242 cd/usr/local/

1243 CD Lib

1244 LS

1245 CD python2.7/

1254 Tar zxf pycrypto-2.6.1.tar.gz

1256 CD pycrypto-2.6.1

1258 python setup.py Install

1259 python

>>> Import Crypto

>>>

1263 Tar Xzf paramiko-2.0.2.tar.gz

1264 CD paramiko-2.0.2

1265 LS

1266 Python setup.py Install

Import Paramiko

Traceback (most recent):

File "setup.py", line A, in <module>

From Setuptools Import Setup

Importerror:no module named Setuptools

1273 Tar xzf setuptools-25.2.0.tar.gz

1274 CD setuptools-25.2.0

1275 ls

1276 python setup.py Install

1277 LS

1278 CD. /paramiko-2.0.2

1279 ls

Python setup.py Install

Missing GCC error

Yum intall-y gcc error due to Python upgrade

# Vim/usr/bin/yum

#!/usr/bin/python2.6 #原本直接为python to a previous version not upgraded

# yum Install gcc libffi-devel python-devel openssl-devel

1281 python

Import Paramiko Error missing module

# wget--no-check-certificate https://github.com/pypa/pip/archive/1.5.5.tar.gz

# tar zxf 1.5.5

# CD PIP-1.5.5/

# python setup.py Install

# PIP Install Paramiko error

Pkg_resources. Distributionnotfound:the ' pip==7.1.0 ' distribution was not found and are required by the application

# Easy_install pip==7.1.0

# pip Install Paramiko

1282 LS

1283 CD

1284 ls

1287 Vim yzh.py

1288 Python yzh.py

1289 Vim yzh.py


2.python SSH Module Login

Import Paramiko

server_ip = ' 192.168.110.59 '

Server_user = ' root '

server_passwd = ' cyl&647308 '

Server_port = 22

SSH = Paramiko. Sshclient ()

Ssh.set_missing_host_key_policy (Paramiko. Autoaddpolicy ()) #无密钥登录

Ssh.connect (SERVER_IP,USERNAME=SERVER_USER,PASSWORD=SERVER_PASSWD)

stdin, stdout, stderr = Ssh.exec_command ("/sbin/ifconfig")

#inf = Stdout.readlines () #输出结果不分行

#print inf

For line in stdout:

print ' ... ' +line.strip (' \ n ') #输出结果分行, according to the command itself display output

Ssh.close ()

print ' Close '


This article is from the "True Water No Fragrance" blog, please be sure to keep this source http://chengyanli.blog.51cto.com/11399167/1846787

Python's Paramiko module

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.