1+ FROM alpine:latest
2+
3+ COPY --chown=root:root server/ssh /etc/ssh/
4+ COPY --chown=root:root server/script /opt/sshnet
5+ COPY user/sshnet /home/sshnet/.ssh
6+
7+ RUN apk update && apk upgrade --no-cache && \
8+ apk add --no-cache syslog-ng && \
9+ # install and configure sshd
10+ apk add --no-cache openssh && \
11+ # install openssh-server-pam to allow for keyboard-interactive authentication
12+ apk add --no-cache openssh-server-pam && \
13+ dos2unix /etc/ssh/* && \
14+ chmod 400 /etc/ssh/ssh*key && \
15+ sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config && \
16+ sed -i 's/#LogLevel\s *INFO/LogLevel DEBUG3/' /etc/ssh/sshd_config && \
17+ echo 'PubkeyAcceptedAlgorithms ssh-rsa' >> /etc/ssh/sshd_config && \
18+ chmod 646 /etc/ssh/sshd_config && \
19+ # install and configure sudo
20+ apk add --no-cache sudo && \
21+ addgroup sudo && \
22+ # allow root to run any command
23+ echo 'root ALL=(ALL) ALL' > /etc/sudoers && \
24+ # allow everyone in the 'sudo' group to run any command without a password
25+ echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers && \
26+ # add user to run most of the integration tests
27+ adduser -D sshnet && \
28+ passwd -u sshnet && \
29+ echo 'sshnet:ssh4ever' | chpasswd && \
30+ dos2unix /home/sshnet/.ssh/* && \
31+ chown -R sshnet:sshnet /home/sshnet && \
32+ chmod -R 700 /home/sshnet/.ssh && \
33+ chmod -R 644 /home/sshnet/.ssh/authorized_keys && \
34+ # add user to administer container (update configs, restart sshd)
35+ adduser -D sshnetadm && \
36+ passwd -u sshnetadm && \
37+ echo 'sshnetadm:ssh4ever' | chpasswd && \
38+ addgroup sshnetadm sudo && \
39+ dos2unix /opt/sshnet/* && \
40+ # install shadow package; we use chage command in this package to expire/unexpire password of the sshnet user
41+ apk add --no-cache shadow && \
42+ # allow us to use telnet command; we use this in the remote port forwarding tests
43+ apk --no-cache add busybox-extras && \
44+ # install full-fledged ps command
45+ apk add --no-cache procps
46+
47+ EXPOSE 22 22
48+
49+ ENTRYPOINT ["/opt/sshnet/start.sh" ]
0 commit comments