python - how to use paramiko ssh object to send remote calls to Windows and Linux server? -
i using python 2.7.6 , paramiko module (on linux server) connect windows server , send commands , output. have connect function takes ip, username , password of remote windows server , sshobj when happens. how use send remote calls question?
if local system, "os.system" not sure remote calls. can help?
my code looks below: sys.path.append("/home/me/code")
import libs.ssh_connect ssh ssh_obj = ssh.new_conn(ip, username, password) stdin, stdout, stderr = ssh_obj.exec_command("dir") #since remote system sshing windows.
my "new_conn" looks this:
import paramiko def new_conn(ip, username, password): ssh_obj = paramiko.sshclient() ssh_conn.set_missing_host_key_policy(paramiko.autoaddpolicy()) ssh_conn.connect(ip, username, password), timeout=30) return ssh_obj
all stdin, stdout , stderror "active; 1 open channel anhd bunch of info channelfile, aes, etc..).
i hoping see output of "dir" windows on linux..
tried "stdout.read()" , "stdout.readlines()" former came out "stdout" , latter came out "[]"!
thanks!
you need add cmd.exe /c
before dir
cmd.exe /c dir
able run commands remotely on windows.
stick exec_command , not try send/recv commands. never got send/recv commands work windows, @ least ssh server using windows (freesshd).
Comments
Post a Comment