Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 connect via ssh to a remote host and run a command locally
#1
Hi everyone,

i'm new to python, please don't hold that against :-)

i'm looking to ssh into a remote computer and run a command locally, this is what i have so far but the local command doesn't seem to run.

if i run it without this command, i receive "Done."
stdin, stdout, stderr = client.exec_command("svt-shutdown-safe")

but when i run it with the above line, it get an error and the "svt-shutdown-safe" command doesn't run.

any help is much appreciated.

import paramiko

try:
    client = paramiko.SSHClient()
    client.load_system_host_keys()
    client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) 

    client.connect("10.0.0.0", port="22", username="MyUsername", password="MyPassword")

    stdin, stdout, stderr = client.exec_command("svt-shutdown-safe")
    
finally:
    client.close()

print ("done.")
Larz60+ wrote Apr-16-2020, 08:06 PM:
Please post all code, output and errors (in it's entirety) between their respective tags. I did it for you this time, Here are instructions on how to do it yourself next time.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  how virtual and host can communicate? looney99 0 342 Nov-28-2019, 09:08 PM
Last Post: looney99

Forum Jump:


Users browsing this thread: 1 Guest(s)