-
Notifications
You must be signed in to change notification settings - Fork 5
Feature cli command reference 63 #155
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
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
04ef0aa
docs: add systemd agent service configuration to Polykey CLI guide
xrissoula 0413b4b
docs: update sidebar
xrissoula aee4d39
fix: correct sidebar path typo for agent systemd doc
xrissoula b32e5a8
fix: correct sidebar doc ID for systemd agent guide
xrissoula 4c010b5
docs: address reviewer suggestions and fix NixOS section
xrissoula 6934350
docs: fix broken sidebar link and clean build cache
xrissoula 5e8a057
docs: add CLI command index page for issue #63
xrissoula a4cda20
docs: fix linting on CLI command reference draft
xrissoula 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # Polykey CLI Command Reference | ||
|
|
||
| This page provides an overview of available `polykey` CLI commands, organized by | ||
| category. | ||
|
|
||
| Each command links to a page with detailed usage, flags, and examples. | ||
|
|
||
| --- | ||
|
|
||
| ## Vault Commands | ||
|
|
||
| - [`vaults create`](./vaults.md) | ||
| - [`vaults list`](./vaults.md) | ||
| - [`vaults unlock`](./vaults.md) | ||
| - [`vaults lock`](./vaults.md) | ||
|
|
||
| ## Secret Commands | ||
|
|
||
| - [`secrets put`](./secrets.md) | ||
| - [`secrets get`](./secrets.md) | ||
| - [`secrets delete`](./secrets.md) | ||
| - [`secrets list`](./secrets.md) | ||
|
|
||
| ## Identity Commands | ||
|
|
||
| - [`identities create`](./identities.md) | ||
| - [`identities list`](./identities.md) | ||
| - [`identities show`](./identities.md) | ||
|
|
||
| ## Key Commands | ||
|
|
||
| - [`keys generate`](./keys.md) | ||
| - [`keys import`](./keys.md) | ||
| - [`keys export`](./keys.md) | ||
|
|
||
| ## Node Commands | ||
|
|
||
| - [`nodes list`](./nodes.md) | ||
| - [`nodes ping`](./nodes.md) | ||
| - [`nodes connect`](./nodes.md) | ||
|
|
||
| ## Notification Commands | ||
|
|
||
| - [`notifications list`](./notifications.md) | ||
| - [`notifications read`](./notifications.md) | ||
|
|
||
| ## Agent Commands | ||
|
|
||
| - [`agent start`](./agent.md) | ||
| - [`agent stop`](./agent.md) | ||
| - [`agent status`](./agent.md) | ||
|
|
||
| ## Bootstrap Command | ||
|
|
||
| - [`bootstrap`](./bootstrap.md) | ||
|
|
||
| ## Audit Command | ||
|
|
||
| - [`audit`](./audit.md) | ||
|
|
||
| --- | ||
|
|
||
| To see detailed help for any command, run: | ||
|
|
||
| ```shell | ||
| polykey -help | ||
| ``` |
186 changes: 186 additions & 0 deletions
186
docs/Getting-Started/polykey-cli/running-the-agent-with-systemd.md
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,186 @@ | ||
| # Polykey Agent: Service and Programs Module Documentation | ||
|
|
||
| This guide introduces and explains the newly added `services` and `programs` | ||
| modules for managing the Polykey Agent using `systemd`. These modules were | ||
| introduced as part of a broader effort to improve automation, reliability, and | ||
| user experience across both user-level and system-wide contexts. | ||
|
|
||
| ## Background | ||
|
|
||
| The Polykey Agent is a long-lived background process that facilitates secure | ||
| secret management and distributed key infrastructure. Traditionally, users had | ||
| to manually start the agent from the terminal. To streamline this, two modules | ||
| were introduced: | ||
|
|
||
| - **programs:** Configures user-level services for personal development and | ||
| desktop use. | ||
| - **services:** Configures system-level services for shared machines and server | ||
| environments. | ||
|
|
||
| These modules utilize `systemd`, a service manager used in most Linux | ||
| distributions. git st :::note Note On NixOS, Polykey is not configured through | ||
| .service files, but instead through the Home Manager or Nix configuration. See | ||
| the NixOS integration section below. ::: | ||
|
|
||
| ## What is systemd? | ||
|
|
||
| systemd is the default init and service manager in most Linux distros. It allows | ||
| you to: | ||
|
|
||
| - Start, stop, and restart background services. | ||
| - Automatically launch services at boot or login. | ||
| - View logs and monitor service health. | ||
|
|
||
| `systemd` uses unit files (like `.service`) to define how services behave. | ||
|
|
||
| ### Key Concepts | ||
|
|
||
| **User vs System Services** | ||
|
|
||
| | Mode | Controlled By | Suitable For | Config Path | | ||
| | ---------- | ------------- | ------------------------------- | ------------------------- | | ||
| | **User** | Regular user | Local development, personal use | `~/.config/systemd/user/` | | ||
| | **System** | Root/admin | Shared systems, production use | `/etc/systemd/system/` | | ||
|
|
||
| The new modules are designed to target both these contexts. | ||
|
|
||
| #### Programs Module (User Services) | ||
|
|
||
| The `programs` module sets up a user-level `systemd` service that: | ||
|
|
||
| - Starts the agent on login. | ||
| - Runs the agent under the current user. | ||
| - Stores logs in the user’s journal. | ||
|
|
||
| ### Setup Instructions (User Mode) | ||
|
|
||
| 1. Ensure the Polykey binary is installed and accessible via `$PATH`. | ||
| 2. Copy the service file to: | ||
|
|
||
| ```sh | ||
| mkdir -p ~/.config/systemd/user | ||
| cp polykey-agent.service ~/.config/systemd/user/ | ||
| ``` | ||
|
|
||
| 3. Enable and start the service: | ||
|
|
||
| ```shell | ||
| systemctl --user daemon-reload | ||
| systemctl --user enable polykey-agent | ||
| systemctl --user start polykey-agent | ||
| ``` | ||
|
|
||
| 4. Verify it’s running: | ||
|
|
||
| ```shell | ||
| systemctl --user status polykey-agent | ||
| journalctl --user -u polykey-agent | ||
| ``` | ||
|
|
||
| #### Services Module (System Services) | ||
|
|
||
| The services module sets up a root-owned service that: | ||
|
|
||
| - Runs globally for all users. | ||
| - Is launched at boot. | ||
| - Is managed from `/etc/systemd/system/`. | ||
|
|
||
| ##### Setup Instructions (System Mode) | ||
|
|
||
| 1. Copy the service file to: | ||
|
|
||
| ```shell | ||
| sudo cp polykey-agent.service /etc/systemd/system/ | ||
| ``` | ||
|
|
||
| 2. Enable and start the service: | ||
|
|
||
| ```shell | ||
| sudo systemctl daemon-reload | ||
| sudo systemctl enable polykey-agent | ||
| sudo systemctl start polykey-agent | ||
| ``` | ||
|
|
||
| 3. Check status: | ||
|
|
||
| ```shell | ||
| sudo systemctl status polykey-agent | ||
| sudo journalctl -u polykey-agent | ||
| ``` | ||
|
|
||
| ## Configuration Details | ||
|
|
||
| The service files can be customized: | ||
|
|
||
| - `ExecStart` can point to any valid Polykey binary. | ||
| - `Environment` variables like `NODE_ENV`, `POLYKEY_DATA_PATH` can be passed in. | ||
| - Restart policies and timeouts can be modified. | ||
|
|
||
| To override a system service without editing the base file: | ||
|
|
||
| ```shell | ||
| sudo systemctl edit polykey-agent | ||
| ``` | ||
|
|
||
| **Note for NixOS users:** These overrides are not applicable. See the next | ||
| section. | ||
|
|
||
| ### Handling Secrets & Recovery Codes | ||
|
|
||
| The new modules support secure handling of recovery codes and agent secrets: | ||
|
|
||
| - Set environment variables or use configuration files in the home directory. | ||
| - Avoid running agents as root unless necessary. | ||
| - For system mode, ensure secrets are stored in restricted root-only paths. | ||
|
|
||
| #### Troubleshooting | ||
|
|
||
| - **“Service not found”:** | ||
|
|
||
| * Run `daemon-reload` after copying or editing unit files. (Not needed in NixOS) | ||
|
|
||
| - **“Permission denied”:** | ||
|
|
||
| * Ensure system-level services are started with `sudo`. | ||
|
|
||
| - **Service not starting:** | ||
|
|
||
| * Run `journalctl -u polykey-agent` for logs. | ||
|
|
||
| - **User services not auto-starting:** | ||
|
|
||
| * Check that `linger` is enabled for the user: | ||
|
|
||
| ```shell | ||
| sudo loginctl enable-linger $USER | ||
| ``` | ||
|
|
||
| ### NixOS Integration | ||
|
|
||
| On NixOS, service setup is handled via Home Manager or system configuration, not | ||
| .service files. Here’s a basic example of configuring Polykey in home.nix: | ||
|
|
||
| ```nix | ||
| polykey = rec { | ||
| enable = true; | ||
| passwordFilePath = "/home/user/.polykeypass"; | ||
| recoveryCodeOutPath = "/home/user/.polykeyrecovery"; | ||
| }; | ||
| ``` | ||
|
|
||
| - enable will activate the service. | ||
| - passwordFilePath provides the path to read the vault password. | ||
| - recoveryCodeOutPath sets the location to write recovery codes. | ||
|
|
||
| **More references:** | ||
|
|
||
| - Polykey Nixpkg (private) | ||
| - Home Manager Infra Docs | ||
|
|
||
| **Use Cases** | ||
|
|
||
| - Developers: Enable `programs` to automatically start the agent at login. | ||
| - Sysadmins: Deploy `services` module for always-on availability of the agent | ||
| across all users. | ||
| - Security-sensitive installations: Customize environment securely and inspect | ||
| logs via `journalctl`. |
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
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.
As was discussed this sprint, https://polykey.com/docs/reference/polykey-cli/commands/ already exists in Polykey docs for referencing the commands and all the commands that exist. The function for some would be obvious, some would be a bit harder to understand. To start off, fill in all the commands you know or were able to figure out, and flag the ones you haven't touched yet.
Then, for each command you are going over, read the relevant section in the documentation and test the different commands/usages yourself using your own polykey agent to confirm if they are still accurate or not. This is important, as we don't want outdated or wrong information, and ChatGPT has a tendency to generate both valid and invalid commands. You need to be careful.
Some commands might have not changed much, like maybe
polykey vaults ls. Confirm by running the commands locally that it matches the expectation, then continue if there's nothing to change.Run polykey locally using
polykey ... --help, where you put the relevant command or subcommand in the.... The--helpflag will tell you the description of the command, and subcommands or arguments if applicable. You can use that to get a preview of the commands and their structure. Make sure the structure on the docs reflect the actual structure locally.