Matthias Hinrichs ea183a08b5
Build And Test / build (push) Successful in 54s
Build And Test / Build and Publish Docker Image (push) Successful in 38s
fix: aktualisiere das Docker-Image auf v0.1.0
2025-11-22 03:19:04 +01:00

Server Management Tool

This is a simple Go application designed to manage your servers, providing functionalities to list, wake up (Wake-on-LAN), shut down, and reboot them. It offers both a command-line interface (CLI) and a web-based interface for convenient management.

Features

  • List Servers: Display all configured servers with their details.
  • Wake Server: Send Wake-on-LAN (WoL) magic packets to bring servers online.
  • Shutdown Server: Remotely shut down servers via SSH.
  • Reboot Server: Remotely reboot servers via SSH.
  • Server Status: Check if servers are online using ping.
  • Web Interface: A user-friendly web interface to perform all management actions.

Prerequisites

Before you begin, ensure you have the following installed:

Getting Started (Local)

  1. Clone the repository:

    git clone git@git.hnrx.net:hnrx/manage-servers.git
    cd manage-servers
    
  2. Configure your servers:

    Edit the servers.json file to include your server details, including MAC addresses for Wake-on-LAN and SSH credentials for shutdown/reboot.

    Example servers.json:

    [
      {
        "name": "harvester-01",
        "mac": "3c:49:37:05:c2:2e",
        "ip": "192.168.110.101",
        "ssh_user": "rancher",
        "ssh_pass": "maddog07"
      }
    ]
    
  3. Run CLI commands:

    go run . list
    go run . wake harvester-01
    go run . status
    go run . shutdown harvester-01
    go run . reboot harvester-01
    
  4. Run the web server locally:

    go run . serve
    

    Access the web interface in your browser at http://localhost:8080.

Getting Started (Docker)

  1. Build the Docker image:

    Navigate to the root of the project and run:

    docker build -t manage-servers:latest .
    
  2. Run the Docker container:

    To enable Wake-on-LAN functionality, the Docker container needs to run in host network mode. This allows it to send broadcast packets directly onto your physical network.

    docker run --network host -p 8080:8080 manage-servers:latest
    
    • --network host: Essential for Wake-on-LAN to work correctly.
    • -p 8080:8080: Maps port 8080 from the container to port 8080 on your host.
  3. Access the web interface:

    Open your web browser and navigate to http://localhost:8080.

Configuration

The servers.json file is crucial for the application's functionality. Ensure it's correctly formatted and contains accurate information for all your servers.

  • name: A unique identifier for your server.
  • mac: The MAC address of the server for Wake-on-LAN.
  • ip: The IP address of the server for SSH connections and status checks.
  • ssh_user: The username for SSH access.
  • ssh_pass: The password for SSH access.

Troubleshooting

Host key verification failed (when pushing to Git)

If you encounter Host key verification failed when pushing to your Git repository, it means your system does not trust the SSH key of the Git server. To resolve this, you need to manually add the server's host key to your ~/.ssh/known_hosts file.

From your terminal, attempt to connect to the server via SSH for the first time:

ssh git@192.168.200.20

When prompted to confirm the host's authenticity, type yes and press Enter. This will add the host key to your known_hosts file, and you should then be able to push your changes.

Error loading servers: open servers.json: no such file or directory (in Docker)

This error indicates that the servers.json file was not found inside the Docker container. Ensure you have the latest Dockerfile (which includes copying servers.json) and rebuild your Docker image.

Sending magic packet from Docker container does not work

If Wake-on-LAN is not working from within the Docker container, it's likely a networking issue. Ensure you are running the Docker container with the --network host flag, as described in the "Run the Docker container" section above. This allows the container to send broadcast packets directly onto your physical network.

S
Description
manage-servers ist ein kleines Tool zum starten, stoppen und rebooten physikalischer Server im Homelab. Es ermöglicht das Starten via WOL für Server, die keine anderen Möglichkeiten bieten.
Readme 165 KiB
v0.1.4 Latest
2026-02-18 14:06:41 +00:00
Languages
HTML 54.1%
Go 44.4%
Dockerfile 1.5%