Small library for shutting down and starting up local server
Project description
This library handles rather specific remote power management scenario: my home network disk
Server can be woken up with wake-on-lan (WOL)
This library validates OpenSSH public keys.
Currently ssh-rsa, ssh-dss (DSA), ssh-ed25519 and ecdsa keys with NIST curves are supported.
Installation:
pip install manage_server_power
or clone the repository and use
python setup.py install
Configuration and notes
On the server side:
Enable WOL (from BIOS/… settings).
Take note of relevant MAC address.
Add new user to server (say, powermanagement).
Edit sudoers (visudo) and add “powermanagement ALL=NOPASSWD: /sbin/poweroff”
On the management computer:
Generate ssh public key pair (ssh-keygen)
Copy public key to powermanagement user on server (add it to .ssh/authorized_keys)
Connect to server to check that public key works properly and to add server host key to known_hosts.
Notes:
At least with some devices/networks, WOL won’t work if broadcast_ip is not set to local network’s broadcast, instead of 255.255.255.255.
Usage
import manage_server_power sp = manage_server_power.ServerPower(server_hostname="example.com", server_mac="61:a3:18:1c:84:4b", server_port=22, # optional, default is 22 ssh_username="powermanagement", broadcast_ip="192.168.1.255", # optional, default is 255.255.255.255 socket_timeout=0.5, # optional wol_port=9, # optional, default is 9 ) print sp.is_alive() # SERVER_DOWN, SERVER_UP or SERVER_UP_NOT_RESPONDING print sp.wake_up() # send WOL packet print sp.shutdown() # ssh in and run "sudo poweroff"
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for manage_server_power-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | de70a73245bc0f45fada745ce1091686b1566ebbd12ef4cf9e9fad2d03a955b8 |
|
MD5 | e35a02b686bcec1ad5e6ca1473c67e53 |
|
BLAKE2b-256 | fdb67f5b86c5c0b48d0fb71ea2fa5ebe1a55f019220ecf290866a5d5165a99c2 |
Hashes for manage_server_power-0.0.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52ad89d6d3a2fdb333e1a83040b4225e05b8d0d8c9ae54cd224ac63348bf2a46 |
|
MD5 | cd92dcaf835b165a82cee0c6781c4484 |
|
BLAKE2b-256 | b2b344f6a44507e812b22a4427fc1924f37ae4dde984eacd99874fb54b9b7b6b |