I'm new at python and i'm trying to create a Python script to SSH (Throw putty), to my server and to execute 'sudo reboot' command (as you probbebly know , sudo is a requied a pass).
as I search here and google, I found this: Python script for SSH through PuTTY
At Putty download page there is 'Plink' I've downloaded that (few version tbh) and it's just open it and close it , not installing something or showme anything. just closing the window soon it's opened. What am I missing? also tried to do that with Paramiko:
import paramiko
host = "myip"
port = 22
username = "myusername"
password = "mypassword"
command = "sudo reboot"
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(host, port, username, password)
stdin, stdout, stderr = ssh.exec_command(command)
ssh.close()
Thank you.