#!/usr/bin/env python
# -*- coding:utf-8 -*-
import paramiko
import uuid
class Ha(object):
def __init__(self):
self.host = '192.168.1.101'
self.port = 22
self.username = 'root'
self.pwd = '' def crate_file(self):
file_name = str(uuid.uuid4())
with open(file_name ,'w') as f:
f.write('')
return file_name
def run(self):
self.connect()
self.Upload()
self.rname()
self.close()
def connect(self):
transport = paramiko.Transport((self.host, self.port))
transport.connect(username=self.username, password=self.pwd)
self.__transport = transport
def close(self):
self.__transport.close()
def Upload(self):
file_name = self.crate_file()
sftp = paramiko.SFTPClient.from_transport(self.__transport)
sftp.put(file_name, '/home/tttttttttttt.py')
def rname(self):
ssh = paramiko.SSHClient()
ssh._transport = self.__transport
stdin,stdout,stderr = ssh.exec_command('mv /home/tttttttttttt.py /home/1111111.py')
result = stdout.read() ha = Ha()
ha.run()

最新文章

  1. position:sticky的兼容性尝试
  2. OC与c混编实现Java的String的hashcode()函数
  3. myeclipse中的weblogic 服务未正常关闭问题解决。
  4. Linux System and Performance Monitoring
  5. CookieStore之Cookie的获取与保存
  6. linux重新设定分区大小
  7. [问题2015S06] 复旦高等代数 II(14级)每周一题(第七教学周)
  8. Jquery 知识表
  9. 继承(引用~析构~virtual)
  10. Android一 流
  11. (一)问候Spring4
  12. Swift Strings and Characters
  13. (转)linux中项目部署和日志查看
  14. DAY10、函数的参数
  15. Day7--------------IP地址配置
  16. vue项目中实现复制内容到剪贴板
  17. CDOJ 1960 构造哈密顿路径
  18. 【开发工具之eclipse】8、The word is not correctly spelled。强迫症看着很难受
  19. 《linux内核设计与实现》第三章
  20. WP8.1 页面跳转,overwrite后退键

热门文章

  1. 百度编辑器ueditor插入表格没有边框,没有颜色的解决方法 2015-01-06 09:24 98人阅读 评论(0) 收藏
  2. QTableView中修改某个单元格或者行或者列内容颜色
  3. Visual Studio 2008 Package Load Failure:未能正确加载包“Microsoft.VisualStudio.Xaml”
  4. 减少生成的dll数量
  5. C#学习笔记-封装
  6. Spring容器深入(li)
  7. 【http抓包】记录一次抓手机app的接口
  8. Lind.DDD.Domain领域模型介绍
  9. ASP.NET MVC导出excel(数据量大,非常耗时的,异步导出)
  10. java web学习总结(二) -------------------TOMCAT使用帮助(一)