-
Notifications
You must be signed in to change notification settings - Fork 0
Credential Management
Yoichi Takizawa edited this page Feb 15, 2026
·
2 revisions
Credentials (IP address, username, password) are resolved in the following priority order:
Command-line arguments > Environment variables > Config file
This allows you to run the script without exposing passwords on the command line.
Create ~/.apcget.conf:
[powerchute]
ip = 192.168.1.100
username = your_username
password = your_passwordSet permissions to owner-only:
chmod 600 ~/.apcget.confRun without any arguments:
python3 apcget.pypython3 apcget.py --config /etc/apcget.confCreate separate config files for each UPS:
# ~/.apcget-ups1.conf
[powerchute]
ip = 192.168.1.100
username = your_username
password = password1
# ~/.apcget-ups2.conf
[powerchute]
ip = 192.168.1.101
username = your_username
password = password2python3 apcget.py --config ~/.apcget-ups1.conf
python3 apcget.py --config ~/.apcget-ups2.conf| Variable | Description |
|---|---|
APCGET_IP |
PowerChute IP address |
APCGET_USERNAME |
Login username |
APCGET_PASSWORD |
Login password |
export APCGET_IP=192.168.1.100
export APCGET_USERNAME=your_username
export APCGET_PASSWORD='your_password'
python3 apcget.pypython3 apcget.py 192.168.1.100 your_username your_passwordWarning: Passing passwords as command-line arguments exposes them via
pscommand and shell history. Use a config file or environment variables instead.
You can combine methods. For example, set IP and username in a config file, and pass the password via an environment variable:
# ~/.apcget.conf
[powerchute]
ip = 192.168.1.100
username = your_usernameexport APCGET_PASSWORD='your_password'
python3 apcget.py