outposts: ensure keypair is set for SSH connections

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2022-02-13 15:39:37 +01:00
parent ff7320b0f8
commit 3b6497cd51

View file

@ -3,6 +3,8 @@ import os
from pathlib import Path from pathlib import Path
from tempfile import gettempdir from tempfile import gettempdir
from docker.errors import DockerException
from authentik.crypto.models import CertificateKeyPair from authentik.crypto.models import CertificateKeyPair
HEADER = "### Managed by authentik" HEADER = "### Managed by authentik"
@ -27,6 +29,8 @@ class DockerInlineSSH:
def __init__(self, host: str, keypair: CertificateKeyPair) -> None: def __init__(self, host: str, keypair: CertificateKeyPair) -> None:
self.host = host self.host = host
self.keypair = keypair self.keypair = keypair
if not self.keypair:
raise DockerException("keypair must be set for SSH connections")
self.config_path = Path("~/.ssh/config").expanduser() self.config_path = Path("~/.ssh/config").expanduser()
self.header = f"{HEADER} - {self.host}\n" self.header = f"{HEADER} - {self.host}\n"