-
-
Notifications
You must be signed in to change notification settings - Fork 52
Add CLI reset-password command documentation #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
renehonig
wants to merge
1
commit into
chirpstack:master
Choose a base branch
from
smartwatt:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,167 @@ | ||
| # Command-line interface | ||
|
|
||
| ChirpStack provides a command-line interface (CLI) for tasks such as resetting | ||
| user passwords, creating API keys, and managing device profiles. These commands | ||
| are useful for automated deployments, scripting, and administration. | ||
|
|
||
| ## Usage | ||
|
|
||
| The CLI is invoked using the `chirpstack` command: | ||
|
|
||
| ```bash | ||
| chirpstack --config <DIRECTORY> <COMMAND> [OPTIONS] | ||
| ``` | ||
|
|
||
| Where `--config` points to the ChirpStack configuration directory (containing | ||
| `chirpstack.toml` and region configuration files). | ||
|
|
||
| ## Available commands | ||
|
|
||
| ### reset-password | ||
|
|
||
| Reset a user's password without API access. This command is useful for: | ||
|
|
||
| - Initial setup of fresh installations | ||
| - Automated deployment scripts | ||
| - Recovery from forgotten passwords | ||
|
|
||
| **Usage:** | ||
|
|
||
| ```bash | ||
| chirpstack --config /etc/chirpstack reset-password --email <EMAIL> [OPTIONS] | ||
| ``` | ||
|
|
||
| **Options:** | ||
|
|
||
| | Option | Description | | ||
| |--------|-------------| | ||
| | `-e, --email <EMAIL>` | User email address (required) | | ||
| | `-p, --password-file <FILE>` | Path to file containing new password | | ||
| | `--stdin` | Read password from stdin | | ||
|
|
||
| **Examples:** | ||
|
|
||
| ```bash | ||
| # Interactive password reset (prompts for password twice) | ||
| chirpstack --config /etc/chirpstack reset-password -e admin@example.com | ||
|
|
||
| # Password from file | ||
| echo "SecurePassword123" > /tmp/pw.txt | ||
| chirpstack --config /etc/chirpstack reset-password -e admin@example.com -p /tmp/pw.txt | ||
|
|
||
| # Password from stdin (recommended for scripts) | ||
| echo "SecurePassword123" | chirpstack --config /etc/chirpstack reset-password -e admin@example.com --stdin | ||
| ``` | ||
|
|
||
| **Security notes:** | ||
|
|
||
| - When using a file, ensure it has restrictive permissions (e.g., `chmod 600`) | ||
| - Always delete password files after use | ||
| - When using stdin, ensure the password is not logged in shell history | ||
|
|
||
| **Password requirements:** | ||
|
|
||
| - Minimum 8 characters | ||
| - Maximum 128 characters | ||
| - NIST 800-63b compliant (no arbitrary complexity requirements) | ||
|
|
||
| ### create-api-key | ||
|
|
||
| Create a global API key for administrative access. | ||
|
|
||
| **Usage:** | ||
|
|
||
| ```bash | ||
| chirpstack --config /etc/chirpstack create-api-key --name <NAME> | ||
| ``` | ||
|
|
||
| **Example:** | ||
|
|
||
| ```bash | ||
| chirpstack --config /etc/chirpstack create-api-key --name "automation-key" | ||
| ``` | ||
|
|
||
| Output: | ||
|
|
||
| ```bash | ||
| id: <UUID> | ||
| token: <JWT_TOKEN> | ||
| ``` | ||
|
|
||
| ### configfile | ||
|
|
||
| Print the configuration template to stdout. | ||
|
|
||
| **Usage:** | ||
|
|
||
| ```bash | ||
| chirpstack --config /etc/chirpstack configfile | ||
| ``` | ||
|
|
||
| ### import-device-profiles | ||
|
|
||
| Import LoRaWAN device profiles from a directory. | ||
|
|
||
| **Usage:** | ||
|
|
||
| ```bash | ||
| chirpstack --config /etc/chirpstack import-device-profiles <DIRECTORY> | ||
| ``` | ||
|
|
||
| ### migrate-device-profile-templates | ||
|
|
||
| Migrate device-profile templates to device profiles. | ||
|
|
||
| **Usage:** | ||
|
|
||
| ```bash | ||
| chirpstack --config /etc/chirpstack migrate-device-profile-templates <DIRECTORY> | ||
| ``` | ||
|
|
||
| ### print-ds | ||
|
|
||
| Print the device-session for debugging (requires --dev-eui). | ||
|
|
||
| **Usage:** | ||
|
|
||
| ```bash | ||
| chirpstack --config /etc/chirpstack print-ds --dev-eui <DEV_EUI> | ||
| ``` | ||
|
|
||
| ## Security considerations | ||
|
|
||
| ### Password handling | ||
|
|
||
| The CLI provides multiple methods for password input, each with different | ||
| security implications: | ||
|
|
||
| | Method | Security | Use case | | ||
| |--------|----------|----------| | ||
| | Interactive prompt | Highest | Manual administration | | ||
| | File (0600 permissions) | Medium | Scripted deployments | | ||
| | Stdin | Low | Pipelines (ensure no history) | | ||
|
|
||
| For scripted deployments using password files: | ||
|
|
||
| ```bash | ||
| # Create password file with restrictive permissions | ||
| echo "SecurePassword123" > /tmp/pw.txt | ||
| chmod 600 /tmp/pw.txt | ||
|
|
||
| # Use in command | ||
| chirpstack --config /etc/chirpstack reset-password -e admin@example.com -p /tmp/pw.txt | ||
|
|
||
| # Immediately delete | ||
| rm /tmp/pw.txt | ||
| ``` | ||
|
|
||
| ### Default credentials | ||
|
|
||
| Upon first installation, ChirpStack creates a default admin user with the | ||
| credentials: | ||
|
|
||
| - Username: `admin` | ||
| - Password: `admin` | ||
|
|
||
| **It is strongly recommended to change this password immediately upon first | ||
| login** using either the web interface or the `reset-password` command. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this example you both (a) hardcode the password directly in the command line and (b) describe stdin as "recommended for scripts", but in the "Password handling" table below stdin is classified as "Low" security and you warn about shell history. Hardcoding the password in the
echocommand will almost always end up in shell history and can also be exposed via process inspection, which conflicts with the security guidance you give later. Consider aligning the recommendation with the table (e.g., recommend the file-based flow for most scripted usage and treat stdin as an advanced option), and update the stdin example to avoid embedding the cleartext password directly in the command line.