Dockerfile 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. # Copyright (c) 2016 Alexander Lamaison <[email protected]>
  2. #
  3. # Redistribution and use in source and binary forms,
  4. # with or without modification, are permitted provided
  5. # that the following conditions are met:
  6. #
  7. # Redistributions of source code must retain the above
  8. # copyright notice, this list of conditions and the
  9. # following disclaimer.
  10. #
  11. # Redistributions in binary form must reproduce the above
  12. # copyright notice, this list of conditions and the following
  13. # disclaimer in the documentation and/or other materials
  14. # provided with the distribution.
  15. #
  16. # Neither the name of the copyright holder nor the names
  17. # of any other contributors may be used to endorse or
  18. # promote products derived from this software without
  19. # specific prior written permission.
  20. #
  21. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  22. # CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  23. # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  24. # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  25. # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  26. # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  27. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  28. # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  29. # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  30. # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  31. # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  32. # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  33. # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
  34. # OF SUCH DAMAGE.
  35. FROM debian:jessie
  36. RUN apt-get update \
  37. && apt-get install -y openssh-server \
  38. && apt-get clean \
  39. && rm -rf /var/lib/apt/lists/*
  40. RUN mkdir /var/run/sshd
  41. # Chmodding because, when building on Windows, files are copied in with
  42. # -rwxr-xr-x permissions.
  43. #
  44. # Copying to a temp location, then moving because chmodding the copied file has
  45. # no effect (Docker AUFS-related bug maybe?)
  46. COPY ssh_host_rsa_key /tmp/etc/ssh/ssh_host_rsa_key
  47. RUN mv /tmp/etc/ssh/ssh_host_rsa_key /etc/ssh/ssh_host_rsa_key
  48. RUN chmod 600 /etc/ssh/ssh_host_rsa_key
  49. COPY ssh_host_ecdsa_key /tmp/etc/ssh/ssh_host_ecdsa_key
  50. RUN mv /tmp/etc/ssh/ssh_host_ecdsa_key /etc/ssh/ssh_host_ecdsa_key
  51. RUN chmod 600 /etc/ssh/ssh_host_ecdsa_key
  52. COPY ssh_host_ed25519_key /tmp/etc/ssh/ssh_host_ed25519_key
  53. RUN mv /tmp/etc/ssh/ssh_host_ed25519_key /etc/ssh/ssh_host_ed25519_key
  54. RUN chmod 600 /etc/ssh/ssh_host_ed25519_key
  55. COPY ca_ecdsa.pub /tmp/etc/ssh/ca_ecdsa.pub
  56. RUN mv /tmp/etc/ssh/ca_ecdsa.pub /etc/ssh/ca_ecdsa.pub
  57. RUN chmod 600 /etc/ssh/ca_ecdsa.pub
  58. COPY ca_ecdsa /tmp/etc/ssh/ca_ecdsa
  59. RUN mv /tmp/etc/ssh/ca_ecdsa /etc/ssh/ca_ecdsa
  60. RUN chmod 600 /etc/ssh/ca_ecdsa
  61. RUN adduser --disabled-password --gecos 'Test user for libssh2 integration tests' libssh2
  62. RUN echo 'libssh2:my test password' | chpasswd
  63. RUN sed -i 's/ChallengeResponseAuthentication no/ChallengeResponseAuthentication yes/' /etc/ssh/sshd_config
  64. RUN echo "TrustedUserCAKeys /etc/ssh/ca_ecdsa.pub" >> /etc/ssh/sshd_config
  65. # SSH login fix. Otherwise user is kicked off after login
  66. RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
  67. USER libssh2
  68. RUN mkdir -p /home/libssh2/.ssh
  69. RUN mkdir -p /home/libssh2/sandbox
  70. COPY authorized_keys /tmp/libssh2/.ssh/authorized_keys
  71. RUN cp /tmp/libssh2/.ssh/authorized_keys /home/libssh2/.ssh/authorized_keys
  72. RUN chmod 600 /home/libssh2/.ssh/authorized_keys
  73. USER root
  74. EXPOSE 22
  75. # -e gives logs via 'docker logs'
  76. CMD ["/usr/sbin/sshd", "-D", "-e"]