Python Forum
connect via ssh to a remote host and run a command locally
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.")
Reply


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

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020