I have a Python program that I'm running in Ubuntu on a local machine. At some point during the program I connect to two remote machines: one running Ubuntu and the other running Windows. I have the IP addresses, names, and passwords to connect to these machines. The local machine sends the remote machines a command, and the remote machines send a response. Right now I'm just trying to get the remote machines to echo 'hello' back to the local machine. I can remote into both of these machines on the command line from my local machine using:
sshpass -p password ssh -X name@ipaddress
where password, name, and ipaddress are correctly filled in for each machine. So I know that I can remote into both of the machines just fine. From there I can run any command as if I was on that machine locally.
However, I would like to do this from within my program while sending in a simple echo 'hello' instruction. I can successfully accomplish this with the remote Ubuntu server with the following:
from subprocess import Popen, PIPE
cmd = ["sshpass", "-p", password, "ssh", "-X", name+"@"+ipaddress, "echo 'hello'"]
ssh = Popen(cmd, stdout=PIPE, stderr=PIPE)
print ssh.stdout.readlines()
The password, name, and ipaddress are variables that are already defined by this point. This works on the Ubuntu remote server where it returns the following list:
['hello\n']
This is good, but when I try the same on the Windows server I get an empty list:
[]
I've tried various commands and I always get an empty list. Is there something else or different that I need to be doing when connecting to the Windows server? Thank you in advance.
I looked at the stderr and that includes the following list:
['X11 forwarding request failed on channel 0\r\n', 'exec request failed on channel 0\r\n']
When I don't include the -X tag then I only get the second error:
['exec request failed on channel 0\r\n']