In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Single login:
#! / bin/bash#-*-coding: utf-8-*-import paramikossh = paramiko.SSHClient () key = paramiko.AutoAddPolicy () ssh.set_missing_host_key_policy (key) pkey = paramiko.RSAKey.from_private_key_file ('/ root/.ssh/id_rsa') ssh.connect ('103.11.30.2, 22,' root', pkey, timeout=5) stdin, stdout Stderr = ssh.exec_command ('ls') print (stdout.read (). Decode ()) print (stderr.read ()) # close the connection ssh.close ()
Read multiple IP and log in line by line, as follows
#! / usr/bin/python#-*-coding: utf-8-*-import time,shutil Osimport paramikoappname = "root" ssh = paramiko.SSHClient () key = paramiko.AutoAddPolicy () ssh.set_missing_host_key_policy (key) pkey = paramiko.RSAKey.from_private_key_file ('/ root/.ssh/id_rsa') uptime = time.strftime ("% Y%m%d") warpath= "/ var/tmp/cslc/aw/update/" + uptimedef update_all_aw (): for line in open ("awip.conf"): print line ssh.connect (line, 22, appname Pkey, timeout=5) stdin, stdout, stderr = ssh.exec_command ('python / var/tmp/awpy/createcopy.py') print (stdout.read (). Decode () print (stderr.read ()) ssh.close () print ("+ next +") return
Awip.conf files can prevent multiple IP addresses.
Reference:
Log in to the host with python key
Pythonparamiko logs in to ssh through key files and has heard of sftp uploading files.
Python uses the paramiko library to remotely and securely connect to SSH
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.