0

I want to run a program on a remote server and send command to it from my computer using subprocess and Paramiko. Is below can be usefull?

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('host', username='user', password="password")
myprogramme = subprocess.Popen("myprogramme.exe", stdin=subprocess.PIPE)
myprogramme.stdin.write(ssh_stdout.read())
myprogramme.communicate("some_inputs\n")
myprogramme.kill
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
scorp
  • 35
  • 1
  • 10

1 Answers1

4

You cannot run a program on a remote server over SSH with subprocess.

Use SSHClient.exec_command to execute your command.

Then you can feed your command to the process using the returned stdin:
Pass input/variables to command/script over SSH using Python Paramiko

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992