1

I want to run a command via ssh on a virtual machine. I'm using paramiko and it works fine except the process ui doesn't open. For example when running notepad, I can see the notepad in task manager but the notepad itself doesn't actually open.

import paramiko
import time

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname="X.X.X.X", username="Administrator", password="Password1")
ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command(r"c:\Windows\System32\notepad.exe")
time.sleep(60)

If you suggest to use different package is also fine.

Thanks

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
Aaron
  • 29
  • 3
  • What's the question? And are you really using Password1 as a password? – kpie Feb 11 '20 at 17:19
  • *Services* (that aren't explicitly configured otherwise) aren't necessarily allowed to connect to the remote GUI at all -- for very good reasons. It's unwise to let software running in the background, that an end-user didn't know was running, get into the event loop; that kind of practice makes it easy to run keyloggers &c. after compromising background services. – Charles Duffy Feb 11 '20 at 17:23
  • It sounds like you're using SSH when you should be using RPC. You'll need an RPC server running on the host (and properly secured -- RPC is a big security hole) and then use a Python RPC client. There's one in the stdlib https://docs.python.org/3/library/xmlrpc.html – Adam Smith Feb 11 '20 at 17:24
  • BTW, note that a good question describes the *specific problem you're having*, not just the thing you're trying to do when you encounter that problem; hence the title edit to specify that the problem you're encountering is that no window is displayed (and specifying the specific OS and windowing system at hand). – Charles Duffy Feb 11 '20 at 17:26
  • BTW, I would suggest checking whether you can successfully start GUI applications over SSH *without* using paramiko, before asking this as a paramiko question at all. If you can't do it with PuTTY or openssh either, no reason to focus in on paramiko. – Charles Duffy Feb 11 '20 at 17:28

0 Answers0