librelist archives

« back to archive

paramiko to execute command on windows

paramiko to execute command on windows

From:
cuision
Date:
2014-09-19 @ 02:52
Hi All,

A error occurs when I use paramiko module on linux to connect window 
machine(Install SSH server) and execute command.

The error is list below:Unable to execute command or shell on remote 
system: Failed to Execute process.

And the code is also list below:import os
import paramiko
def sshhost(ip,username,password,cmd):
    try:
        ssh = paramiko.SSHClient()
        ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        ssh.connect('192.168.5.111',22,'Administrator','12345')
        stdin,stdout,stderr = ssh.exec_command(cmd)
        print stdout.read()
        print stderr.read()
        ssh.close()
    except:
        print '%s:error'%'192.168.5.111'

def main():
    sshhost('192.168.5.111','Administrator','12345','echo hello')
  
                                                         
I do not how to fix this issue, so ask you for help and thanks in advance!