Chinaunix首页 | 论坛 | 博客
  • 博客访问: 23630
  • 博文数量: 20
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 207
  • 用 户 组: 普通用户
  • 注册时间: 2013-08-26 09:51
文章分类

全部博文(20)

分类: Python/Ruby

2013-10-09 15:13:49

install paramiko steps:

  1. downloadparamiko.zip,unzip the compressed file

  2. find pycrypto, install the moudle

  3. find paramiko-1.7.7.1.zip, unzip the file

  4. python setup.py install in cmd


testing code:


  1. import paramiko
  2.          
  3. hostname='192.168.0.106'
  4. username='root'
  5. password='123456'
  6.          
  7. if __name__=='__main__':
  8.         paramiko.util.log_to_file('paramiko.log')
  9.         s=paramiko.SSHClient()
  10.         #s.load_system_host_keys()
  11.         s.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  12.         s.connect(hostname = hostname,username=username, password=password)
  13.         stdin,stdout,stderr=s.exec_command('ls')
  14.         output = stdout.read()
  15.         f =open('abc','w')
  16.         f.write(output)
  17.         f.close()
  18.         s.close()

 

阅读(414) | 评论(0) | 转发(0) |
0

上一篇:reset user password

下一篇:抽象类和接口

给主人留下些什么吧!~~