远程 paramiko

 1 #!/usr/bin/env python
 2 
 3 
 4 import paramiko
 5 
 6 hostname='192.168.4.5'
 7 user='root'
 8 password=123456
 9 
10 ssh = paramiko.SSHClient()
11 ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
12 ssh.connect(hostname, username=user, password=password)
13 
14 stdin, stdout, stderr = ssh.exec_command('touch /root/paramiko.txt')
15 print stdin.read()
16 
17 ssh.close()

 

posted @ 2018-03-23 17:09  hrwu  阅读(79)  评论(0)    收藏  举报