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
  • 167,268
  • 50
  • 405
  • 846
scorp
  • 35
  • 9

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
  • 167,268
  • 50
  • 405
  • 846