Skip to content

Credential Management

Yoichi Takizawa edited this page Feb 15, 2026 · 2 revisions

Credential Management

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.

Method 1: Config File (Recommended)

Create ~/.apcget.conf:

[powerchute]
ip = 192.168.1.100
username = your_username
password = your_password

Set permissions to owner-only:

chmod 600 ~/.apcget.conf

Run without any arguments:

python3 apcget.py

Custom config path

python3 apcget.py --config /etc/apcget.conf

Multiple UPS units

Create 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 = password2
python3 apcget.py --config ~/.apcget-ups1.conf
python3 apcget.py --config ~/.apcget-ups2.conf

Method 2: Environment Variables

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

Method 3: Command-line Arguments

python3 apcget.py 192.168.1.100 your_username your_password

Warning: Passing passwords as command-line arguments exposes them via ps command and shell history. Use a config file or environment variables instead.

Mixing Methods

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_username
export APCGET_PASSWORD='your_password'
python3 apcget.py

Clone this wiki locally