diff --git a/elements/debian/element-deps b/elements/debian/element-deps index 0f508629..1c0ebe24 100644 --- a/elements/debian/element-deps +++ b/elements/debian/element-deps @@ -1 +1,2 @@ debian-minimal +openssh-server diff --git a/elements/debian/package-installs.yaml b/elements/debian/package-installs.yaml index 92d0131d..97829bce 100644 --- a/elements/debian/package-installs.yaml +++ b/elements/debian/package-installs.yaml @@ -1,4 +1,3 @@ -openssh-server: file: less: kbd: diff --git a/elements/dynamic-login/element-deps b/elements/dynamic-login/element-deps index 74451ffb..34c57c76 100644 --- a/elements/dynamic-login/element-deps +++ b/elements/dynamic-login/element-deps @@ -1,3 +1,3 @@ dib-init-system install-static -package-installs +openssh-server diff --git a/elements/local-config/element-deps b/elements/local-config/element-deps index 7076aba9..dd21b5aa 100644 --- a/elements/local-config/element-deps +++ b/elements/local-config/element-deps @@ -1 +1 @@ -package-installs +openssh-server diff --git a/elements/local-config/package-installs.yaml b/elements/local-config/package-installs.yaml deleted file mode 100644 index c342a0be..00000000 --- a/elements/local-config/package-installs.yaml +++ /dev/null @@ -1 +0,0 @@ -openssh-server: diff --git a/elements/openssh-server/README.rst b/elements/openssh-server/README.rst new file mode 100644 index 00000000..7190deab --- /dev/null +++ b/elements/openssh-server/README.rst @@ -0,0 +1,14 @@ +============== +openssh-server +============== +This element ensures that openssh server is installed and enabled during boot. + + +Note +---- +Most cloud images come with the openssh server service installed and enabled +during boot. However, certain cloud images, especially those created by the +\*-minimal elements may not have it installed or enabled. In these cases, +using this element may be helpful to ensure your image will accessible via SSH. +It's usually helpful to combine this element with others such as the +`runtime-ssh-host-keys`. diff --git a/elements/openssh-server/element-deps b/elements/openssh-server/element-deps new file mode 100644 index 00000000..fe8fa3f8 --- /dev/null +++ b/elements/openssh-server/element-deps @@ -0,0 +1,3 @@ +dib-init-system +package-installs +runtime-ssh-host-keys diff --git a/elements/dynamic-login/package-installs.yaml b/elements/openssh-server/package-installs.yaml similarity index 100% rename from elements/dynamic-login/package-installs.yaml rename to elements/openssh-server/package-installs.yaml diff --git a/elements/openssh-server/pkg-map b/elements/openssh-server/pkg-map new file mode 100644 index 00000000..9b039341 --- /dev/null +++ b/elements/openssh-server/pkg-map @@ -0,0 +1,10 @@ +{ + "family": { + "suse": { + "openssh-server": "openssh" + }, + "gentoo": { + "openssh-server": "openssh" + } + } +} diff --git a/elements/openssh-server/post-install.d/80-enable-sshd-service b/elements/openssh-server/post-install.d/80-enable-sshd-service new file mode 100755 index 00000000..50238bbc --- /dev/null +++ b/elements/openssh-server/post-install.d/80-enable-sshd-service @@ -0,0 +1,29 @@ +#!/bin/bash + +if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then + set -x +fi +set -eu +set -o pipefail + +case "$DIB_INIT_SYSTEM" in + upstart) + # nothing to do + exit 0 + ;; + systemd) + if [[ $DISTRO_NAME = "ubuntu" || $DISTRO_NAME = "debian" ]]; then + systemctl enable ssh.service + else + systemctl enable sshd.service + fi + ;; + openrc) + # let dib-init-system's postinstall handle enabling init scripts + exit 0 + ;; + *) + echo "Unsupported init system" + exit 1 + ;; +esac diff --git a/releasenotes/notes/openssh-server-0f6d065748a2fc18.yaml b/releasenotes/notes/openssh-server-0f6d065748a2fc18.yaml new file mode 100644 index 00000000..985475b8 --- /dev/null +++ b/releasenotes/notes/openssh-server-0f6d065748a2fc18.yaml @@ -0,0 +1,4 @@ +--- +features: + - New openssh-server element to ensure that the openssh + server is installed and enabled during boot.