Configuration¶
This guide explains how to configure the PAN-OS CLI tool for connecting to your Palo Alto Networks devices.
Authentication Methods¶
pan-os-cli
offers multiple ways to configure your authentication credentials:
- Environment variables
- Configuration file
- Command-line arguments (coming soon)
Environment Variables¶
Environment variables provide a quick way to set your credentials without modifying files. These variables are read each time you run a command.
Recommended Method (Uppercase with PANOS_ prefix)¶
export PANOS_USERNAME="your-username"
export PANOS_PASSWORD="your-password" # pragma: allowlist secret
export PANOS_HOSTNAME="panorama.example.com"
These uppercase environment variables with the PANOS_
prefix are the recommended and most reliable way to set your credentials.
Important: While the application also checks for lowercase environment variables, these may not be recognized in all scenarios. We recommend using the uppercase
PANOS_
prefixed variables for consistent behavior.
Configuration File¶
For persistent configuration, you can create a YAML configuration file at ~/.pan-os-cli/config.yaml
:
# PAN-OS CLI Configuration
default:
# Authentication settings
username: "your-username"
password: "your-password" # pragma: allowlist secret
hostname: "panorama.example.com"
# api_key: "your-api-key" # pragma: allowlist secret
# Application settings
thread_pool_size: 10 # Number of concurrent threads
mock_mode: false # Whether to run in mock mode
Configuration File Location¶
By default, the CLI looks for a configuration file at ~/.pan-os-cli/config.yaml
. You can create this file manually or specify a different path using command-line options.
Configuration Precedence¶
When multiple configuration methods are used, the CLI follows this precedence order (highest to lowest):
- Command-line arguments (when implemented)
- Environment variables (uppercase
PANOS_
prefix) - Environment variables (lowercase)
- Configuration file
- Default values
Testing Your Configuration¶
You can verify that your configuration is working properly by running:
This command will connect to your PAN-OS device and display information about the successful connection.
Setting Up Different Environments¶
Dynaconf (the configuration library used by pan-os-cli
) supports environment-specific configuration. You can define different environments in your config file:
default:
username: "default-username"
password: "default-password" # pragma: allowlist secret
hostname: "default-hostname.example.com"
development:
hostname: "dev-panorama.example.com"
production:
hostname: "prod-panorama.example.com"
To use a specific environment, set the PANOS_ENV
environment variable:
Troubleshooting¶
If you're experiencing connection issues:
- Ensure you're using the uppercase
PANOS_
prefixed environment variables - Verify the hostname is correct and the device is reachable
- Check your credentials are correct
- Run with
--mock
flag to test without making actual API calls - Check the error messages for specific connection issues
Security Best Practices¶
- Never store credentials in scripts or version control
- Consider using API keys instead of username/password when possible
- Use environment variables for ephemeral access
- Restrict file permissions on your configuration file:
chmod 600 ~/.pan-os-cli/config.yaml