|
| 1 | +# `sshd` promise type |
| 2 | + |
| 3 | +Configures sshd and restarts the service when configuration changes. |
| 4 | + |
| 5 | +## Promiser |
| 6 | +An arbitrary human-readable label that appears in log messages and reports. |
| 7 | +Since there is only one global sshd configuration, the promiser is not used to identify a resource. |
| 8 | +Example: `"global sshd config"`. |
| 9 | + |
| 10 | +## Attributes |
| 11 | +- Named using sshd's native directive names (e.g. `PermitRootLogin`, not `permit_root_login`) |
| 12 | +- Values can be strings or slists |
| 13 | +- Validated against `sshd -t` during promise evaluation |
| 14 | + |
| 15 | +## What the module manages internally |
| 16 | +1. **Include directive** — ensures the base `sshd_config` includes the drop-in directory (`sshd_config.d/`) as its first non-comment directive |
| 17 | +2. **Drop-in directory** — creates the drop-in directory if it doesn't exist |
| 18 | +3. **Drop-in file** — writes directives to `sshd_config.d/00-cfengine.conf` |
| 19 | +4. **Service restart** — restarts sshd if configuration was changed and the service is already running |
| 20 | +5. **Verification** — verifies the desired attributes appear in the effective sshd config (`sshd -T`) |
| 21 | + |
| 22 | +## What the module does NOT do |
| 23 | +- Install sshd — that is a `packages:` promise |
| 24 | +- Ensure sshd is running — that is a `services:` promise |
| 25 | +- Manage match blocks — those are a policy-level concern |
| 26 | + |
| 27 | +## Policy |
| 28 | +```cf3 |
| 29 | +bundle agent sshd_config |
| 30 | +{ |
| 31 | + packages: |
| 32 | + "openssh-server" |
| 33 | + policy => "present"; |
| 34 | +
|
| 35 | + services: |
| 36 | + "sshd" |
| 37 | + service_policy => "start"; |
| 38 | +
|
| 39 | + vars: |
| 40 | + "allowed_users" slist => { "alice", "bob" }; |
| 41 | +
|
| 42 | + sshd: |
| 43 | + "global" |
| 44 | + PermitRootLogin => "no", |
| 45 | + PasswordAuthentication => "no", |
| 46 | + Port => "22", |
| 47 | + AllowUsers => @(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