Dockerfile.TestServer 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. FROM alpine:latest
  2. COPY --chown=root:root server/ssh /etc/ssh/
  3. COPY --chown=root:root server/script /opt/sshnet
  4. COPY user/sshnet /home/sshnet/.ssh
  5. RUN apk update && apk upgrade --no-cache && \
  6. apk add --no-cache syslog-ng && \
  7. # install and configure sshd
  8. apk add --no-cache openssh && \
  9. # install openssh-server-pam to allow for keyboard-interactive authentication
  10. apk add --no-cache openssh-server-pam && \
  11. # must not use * for dos2unix parameter otherwise it tries to process folders too and fails
  12. dos2unix /etc/ssh/ssh*key && \
  13. chmod 400 /etc/ssh/ssh*key && \
  14. sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config && \
  15. sed -i 's/#LogLevel\s*INFO/LogLevel DEBUG3/' /etc/ssh/sshd_config && \
  16. # Set the default RSA key
  17. echo 'HostKey /etc/ssh/ssh_host_rsa_key' >> /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. # must not use * for dos2unix parameter otherwise it tries to process folders too and fails
  31. dos2unix /home/sshnet/.ssh/*_key* && \
  32. chown -R sshnet:sshnet /home/sshnet && \
  33. chmod -R 700 /home/sshnet/.ssh && \
  34. chmod -R 644 /home/sshnet/.ssh/authorized_keys && \
  35. # add user to administer container (update configs, restart sshd)
  36. adduser -D sshnetadm && \
  37. passwd -u sshnetadm && \
  38. echo 'sshnetadm:ssh4ever' | chpasswd && \
  39. addgroup sshnetadm sudo && \
  40. dos2unix /opt/sshnet/* && \
  41. # install shadow package; we use chage command in this package to expire/unexpire password of the sshnet user
  42. apk add --no-cache shadow && \
  43. # allow us to use telnet command; we use this in the remote port forwarding tests
  44. apk --no-cache add busybox-extras && \
  45. # install full-fledged ps command
  46. apk add --no-cache procps
  47. EXPOSE 22 22
  48. ENTRYPOINT ["/opt/sshnet/start.sh"]