charmed-openssh-ssh-config-interface
Usage
The ssh_config interface enables charms to provide custom OpenSSH server
configuration to a subordinate charm such as the openssh operator. A provider
- for example, like the SSSD charm that needs the SSH daemon to query an LDAP server
for user public keys - sends configuration snippets that the requirer writes
into
/etc/ssh/ssh_config.d/.
To install, add charmed-openssh-ssh-config-interface to your Python
dependencies. Then in your Python code, import as:
from charmed_openssh_ssh_config_interface import (
SSHConfigConnectedEvent,
SSHConfigData,
SSHConfigDisconnectedEvent,
SSHConfigProvider,
SSHConfigReadyEvent,
SSHConfigRequirer,
)
Direction
The ssh_config interface implements a provider/requirer pattern.
The Provider supplies custom SSH daemon configuration through the integration
application databag.
The Requirer consumes that configuration and applies it to the local SSH
daemon.
flowchart TD
Provider -- ssh_config --> Requirer
Behavior
Provider
- Emits
ssh_config_connectedwhen a requirer joins the integration. - Sets the
ssh_configkey in the application databag viaset_config_data. - Only writes data when the unit is the application leader.
- Uses
set_config_datato serialize anSSHConfigDataobject into the application databag.
Requirer
- Observes
relation_changedand emitsssh_config_readywhen the provider's application databag contains the requiredssh_configfield. - Observes
relation_brokenand emitsssh_config_disconnectedwhen the provider application departs. - Calls
get_config_datato deserialize theSSHConfigDataobject from the integration databag.
Integration data
A single field, ssh_config, is exchanged through the integration's application
databag. No data flows in the reverse direction and no Juju Secrets are used.
Example
provider:
app:
ssh_config: "AuthorizedKeysCommand /usr/bin/sss_ssh_authorizedkeys"
unit: {}
requirer:
app: {}
unit: {}
Examples
Provider charm
import ops
from charmed_openssh_ssh_config_interface import (
SSHConfigConnectedEvent,
SSHConfigData,
SSHConfigProvider,
)
class ExampleProviderCharm(ops.CharmBase):
"""Charm that provides SSH daemon configuration."""
def __init__(self, framework: ops.Framework) -> None:
super().__init__(framework)
self._ssh_config = SSHConfigProvider(self, "ssh-config")
framework.observe(
self._ssh_config.on.ssh_config_connected,
self._on_ssh_config_connected,
)
def _on_ssh_config_connected(self, event: SSHConfigConnectedEvent) -> None:
data = SSHConfigData(
ssh_config="AuthorizedKeysCommand /usr/bin/sss_ssh_authorizedkeys\n"
)
self._ssh_config.set_config_data(data, integration_id=event.relation.id)
Requirer charm
import ops
from charmed_openssh_ssh_config_interface import (
SSHConfigData,
SSHConfigReadyEvent,
SSHConfigRequirer,
)
class ExampleRequirerCharm(ops.CharmBase):
"""Charm that consumes SSH daemon configuration."""
def __init__(self, framework: ops.Framework) -> None:
super().__init__(framework)
self._ssh_config = SSHConfigRequirer(self, "ssh-config")
framework.observe(
self._ssh_config.on.ssh_config_ready,
self._on_ssh_config_ready,
)
def _on_ssh_config_ready(self, event: SSHConfigReadyEvent) -> None:
data = self._ssh_config.get_config_data(event.relation.id)
if data is not None:
# Write `data.ssh_config` to `/etc/ssh/ssh_config.d/` and
# reload the SSH daemon.
self.unit.status = ops.ActiveStatus()
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file charmed_openssh_ssh_config_interface-0.1.0.tar.gz.
File metadata
- Download URL: charmed_openssh_ssh_config_interface-0.1.0.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74478f49cdf6d4ea2c417aed4ccf36aab8d0a483422b8377004be7ea7e9ab800
|
|
| MD5 |
9c4ff2db0875251ff3b570068e98d224
|
|
| BLAKE2b-256 |
b6aeab1794b31cf464cbb4597e62a5c275dea8f35c42e3a5fdff101efb15908c
|
File details
Details for the file charmed_openssh_ssh_config_interface-0.1.0-py3-none-any.whl.
File metadata
- Download URL: charmed_openssh_ssh_config_interface-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c05626c7e73ad1151f5317a0987e65755ad1540529aa9e8451f4e407f4d6cd8
|
|
| MD5 |
9d2e64afd08df59a7a27c279e52adbea
|
|
| BLAKE2b-256 |
53cd7f644d4614457d98eee11f66d0e59b25bd9d9ee3170f8de4210edf5721d0
|