|
| 1 | +# `sshd` promise type |
| 2 | + |
| 3 | +Configures sshd and restarts the service when configuration changes. |
| 4 | + |
| 5 | +## Promiser |
| 6 | +The sshd configuration keyword to manage (e.g. `PermitRootLogin`, `AllowUsers`). |
| 7 | +Each promise manages a single directive in the drop-in config file. |
| 8 | + |
| 9 | +## Attributes |
| 10 | +- `value` (required) — the value for the directive, either a string or an slist |
| 11 | + |
| 12 | +## What the module manages internally |
| 13 | +1. **Include directive** — ensures the base `sshd_config` includes the drop-in directory (`sshd_config.d/`) as its first non-comment directive |
| 14 | +2. **Drop-in directory** — creates the drop-in directory if it doesn't exist |
| 15 | +3. **Drop-in file** — writes directives to `sshd_config.d/00-cfengine.conf` |
| 16 | +4. **Service restart** — restarts sshd if configuration was changed and the service is already running |
| 17 | +5. **Verification** — verifies the desired directive appears in the effective sshd config (`sshd -T`) |
| 18 | + |
| 19 | +## Conflicting promisers |
| 20 | +Having multiple promises with the same sshd keyword is not recommended. |
| 21 | +In case of conflicting promisers, the agent will attempt to converge the correct state for each one in the order they are evaluated. |
| 22 | +This means the last promise wins and determines the final value in the configuration file. |
| 23 | +It will also cause multiple restarts of the sshd service, which may be disruptive. |
| 24 | + |
| 25 | +## What the module does NOT do |
| 26 | +- Install sshd — that is a `packages:` promise |
| 27 | +- Ensure sshd is running — that is a `services:` promise |
| 28 | +- Manage match blocks — those are a policy-level concern |
| 29 | + |
| 30 | +## Policy |
| 31 | +```cf3 |
| 32 | +bundle agent sshd_config |
| 33 | +{ |
| 34 | + packages: |
| 35 | + "openssh-server" policy => "present"; |
| 36 | +
|
| 37 | + services: |
| 38 | + "sshd" service_policy => "start"; |
| 39 | +
|
| 40 | + vars: |
| 41 | + "allowed_users" slist => { "alice", "bob" }; |
| 42 | +
|
| 43 | + sshd: |
| 44 | + "PermitRootLogin" value => "no"; |
| 45 | + "PasswordAuthentication" value => "no"; |
| 46 | + "Port" value => "22"; |
| 47 | + "AllowUsers" value => @(allowed_users); |
| 48 | +} |
| 49 | +``` |
| 50 | + |
| 51 | +## Authors |
| 52 | + |
| 53 | +This software was created by the team at [Northern.tech](https://northern.tech), with many contributions from the community. |
| 54 | +Thanks everyone! |
| 55 | + |
| 56 | +## Contribute |
| 57 | + |
| 58 | +Feel free to open pull requests to expand this documentation, add features, or fix problems. |
| 59 | +You can also pick up an existing task or file an issue in [our bug tracker](https://northerntech.atlassian.net/). |
| 60 | + |
| 61 | +## License |
| 62 | + |
| 63 | +This software is licensed under the MIT License. See LICENSE in the root of the repository for the full license text. |
0 commit comments