Skip to main content

Small library for shutting down and starting up local server

Project description

This library handles rather specific remote power management scenario.

  • Server can be woken up with wake-on-lan (WOL)

  • SSH access with public key authentication to the server (for shutting it down)

  • Server responds to ping (checking whether the server is running)


pip install manage_server_power

or clone the repository and use

python 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.


  • At least with some devices/networks, WOL won’t work if broadcast_ip is not set to local network’s broadcast, instead of


import manage_server_power
sp = manage_server_power.ServerPower(server_hostname="",
                                     server_port=22,  # optional, default is 22
                                     broadcast_ip="",  # optional, default is
                                     socket_timeout=0.5,  # optional
                                     wol_port=9,  # optional, default is 9
print sp.is_alive()
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

manage_server_power-0.0.6.tar.gz (3.1 kB view hashes)

Uploaded source

Built Distribution

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page