Skip to content

Commit fb0c0cb

Browse files
authored
Adds an SSH daemon to the cnf-test-partner image (#311)
* Adds an SSH daemon to the cnf-test-partner image The default entrypoint keeps being the webserver. To lauch the SSH daemon the following command can be used: /usr/sbin/sshd -f /home/tnf-user/sshd/sshd_config -D -d To be used for testing purposes. * Fix linting error
1 parent fe449c1 commit fb0c0cb

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

test-partner/Dockerfile

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,19 @@ RUN \
1111
iproute \
1212
iputils \
1313
make \
14-
openssh \
14+
openssh-server \
1515
openssh-clients \
1616
podman \
1717
psmisc \
1818
wget \
1919
&& dnf clean all --assumeyes --disableplugin=subscription-manager \
2020
&& rm -rf /var/cache/yum
2121

22+
# Create user and group
23+
RUN \
24+
groupadd --gid $USER_GID $USERNAME \
25+
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME
26+
2227
# Install Go binary
2328
ENV \
2429
GO_BIN_TAR=go1.20.6.linux-amd64.tar.gz \
@@ -38,6 +43,13 @@ RUN \
3843
# Add go and oc binary directory to $PATH
3944
ENV PATH="/bin/":"/usr/local/go/bin":${GOPATH}"/bin/":"${PATH}"
4045

46+
# Configure SSH daemon
47+
WORKDIR /home/${USERNAME}/sshd
48+
RUN \
49+
printf 'Port 2222\nHostKey /home/%s/sshd/ssh_host_rsa_key\nPidFile /home/%s/sshd/sshd.pid\n' "$USERNAME" "$USERNAME" >> sshd_config \
50+
&& ssh-keygen -t rsa -f /home/${USERNAME}/sshd/ssh_host_rsa_key -N '' \
51+
&& chown -R $USERNAME:$USERNAME /home/${USERNAME}/sshd
52+
4153
# Add arbitrary /licenses folder to pass preflight
4254
RUN \
4355
mkdir /licenses \
@@ -50,8 +62,6 @@ WORKDIR /app/testapp
5062
RUN make build
5163
ARG LIVENESS_PROBE_DEFAULT_PORT=8080
5264
EXPOSE ${LIVENESS_PROBE_DEFAULT_PORT}
53-
RUN \
54-
groupadd --gid $USER_GID $USERNAME \
55-
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME
65+
5666
USER $USERNAME
5767
CMD ["./bin/app"]

0 commit comments

Comments
 (0)