Python paramiko Example
### RUN INSTRUCTION###PYTHON PROGRAMNAME.PY <HOST_IP> <HOST_PASSWORD> <LINUX_COMMAND>
######################################################################3
import sys, paramiko
if len(sys.argv) < 4:
print ("args missing")
sys.exit(1)
hostname = sys.argv[1]
password = sys.argv[2]
command = sys.argv[3]
username = "root"
port = 22
try:
client = paramiko.SSHClient()
client.load_system_host_keys()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
# client.set_missing_host_key_policy(paramiko.WarningPolicy())
client.connect(hostname, port=port, username=username, password=password)
stdin, stdout, stderr = client.exec_command(command)
print (stdout.read())
finally:
client.close()
##########################################################
Usually I never comment on blogs but your article is so convincing that I never stop myself to say something about it. Facebook bellen nederland
ReplyDelete