Python3.5-ssh Password-free procedure

Source: Internet
Author: User
Tags install openssl

SSH remote batch Execution command to lose password very painful, although there are many ways, there are about 4, 5 kinds. The principle is basically similar. Here, I'll talk about a Python analog login module.

The time is: November 19, 2015 11:11:47 basically all the latest in the official website, in addition to CentOS--! The following link is also the current official website of the latest installation package. I am Lei Feng

Environment: CentOS 6.6

python:3.5 wget https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tgz

paramiko:1.7.7.1 wget http://www.lag.net/paramiko/download/paramiko-1.7.7.1.tar.gz

pip:7.1.2 wget https://pypi.python.org/packages/source/p/pip/pip-7.1.2.tar.gz

Setuptools:wget Https://bootstrap.pypa.io/ez_setup.py-O-| Python

pycrypto2.6 https://ftp.dlitz.net/pub/dlitz/crypto/pycrypto/pycrypto-2.6.1.tar.gz

First, install the Paramiko module

Python simulation login needs to install the Paramiko module, and the Paramiko module is dependent on pycrypto2.6 this has a version limit, is not too low version, here we can be Paramiko setup.py installation file to see the statement

There is also the Python version supported by this module, which is supported by the latest 3.5

So much nonsense, start installing it.

Install OpenSSL and Openssl-devel first because these 2 packages are to be installed before installing python3.5, or they will be reported in the future if you install Pip

If such an error occurs, first install the above 2 packages, and then delete the Python installation directory, re-install Python.

OpenSSL is good for installing with Yum. Yum defaults to python2.6 's interpretation environment, changing the system's default Python to 3 and remembering to change Yum's interpretation environment. python3.5 installation here will not BB.

Yum-y Install OpenSSL Openssl-devel

Then install python3.5 and change python3.5 to Python default interpretation.

Compile times Error:error:command ' gcc ' failed with exit status 1; This is due to a missing Python-dev package, yum-y install Python-devel

Ln-s/usr/local/bin/python3/usr/bin/python

Install a dependent module setuptools before installing PIP:

wget Https://bootstrap.pypa.io/ez_setup.py-O-| Python

Install PIP

Tar zxf pip-7.1.2.tar.gz

CD pip-7.1.2

Python setup.py build && python setup.py install

Next, install the Paramiko dependent module pycrypto2.6

Tar zxf pycrypto2.6.tar.gz

CD pycrypto2.6

Python setup.py build && python setup.py install

Then install the paramiko-1.7.7

Tar zxf paramiko-1.7.7.tar.gz

CD paramiko-1.7.7

Python setup.py build && python setup.py install

Then we'll test the module in Python to see if it's installed.

If the other system has an error, the above module is not installed with PIP install can be installed. The module is now installed.

Second, the function realization

#/usr/bin/python
#++++++++++++++++++++++++++this version Python3.5+++++++++++++++++++syw
Import Paramiko
Ipadd = str (input ("Enter your IPAddr:"))
cmd = str (input ("Enter your Command:"))
Port = 22
name = "Root"
PWD = "Yingzi"
SSH = Paramiko. Sshclient ()
Ssh.set_missing_host_key_policy (Paramiko. Autoaddpolicy ())
Ssh.connect (IPADD,PORT,NAME,PWD)
Stdin,stdout,stderr = Ssh.exec_command (cmd)
Print (Stdout.readlines (), end= ")
Ssh.close ()

Where stdout returns the result of the command, the format is very messy. I don't know what the reason is.  Want to know the great God to the younger brother to nudge. Thank you

Python3.5-ssh Password-free procedure

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.