Python Api to Reboot Antminer

Sep 30, 2018

Cgiminer Api has a restart command, but it require configuration to allow the priviledged command, and I doubt it restart the entire machine.

Instead, I opt to write code to SSH into the machine and issue a reboot command. The downside is root/admin username and password is required.

I use Paramiko for Python SSH support.

import paramikodef reboot(ip):  ssh = paramiko.SSHClient()  # paramiko.ssh_exception.SSHException: Server '192.168.1.1' not found in known_hosts  ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())  ssh.connect(ip, username='root', password='password')  # ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command("ls -a")  ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command("/sbin/reboot")  # print ssh_stdin.readlines()  print ssh_stdout.readlines()  print ssh_stderr.readlines()

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.