A little preamble: some CICD integration tests need to be able to connect via ssh to a user with a suite of test files in its home directory. This is the Dockerfile I wrote to create that:
FROM alpine:latest
WORKDIR /src
COPY ./src /src
RUN apk update
RUN apk add bash
RUN apk add openssh
RUN apk add openrc
RUN rc-update add sshd
RUN adduser -g "" -D testuser
RUN echo testuser:testpassword | chpasswd
EXPOSE 22
That builds an image that I then mount interactively to stop it from immediately exiting.
docker run -dit --rm -p 5022:22 6dbd5f8ae874
At this point I was expecting to be able to connect:
ssh testuser@localhost -p 5022
but ssh says
kex_exchange_identification: Connection closed by remote host
Connection closed by 127.0.0.1 port 5022
Remembering that the context for this is Alpine Linux as at 2022-07-06:
- Which needs changing - client, server or both?
- How and where?