Debian Codegraph @

tests/openssh_server/Dockerfile

raw
1 # Copyright (C) Alexander Lamaison <[email protected]>
2 # SPDX-License-Identifier: BSD-3-Clause
3
4 FROM debian:testing-slim
5
6 RUN apt-get update \
7 && apt-get install -y openssh-server \
8 && apt-get clean \
9 && rm -rf /var/lib/apt/lists/*
10 RUN [ -d /var/run/sshd ] || mkdir /var/run/sshd
11
12 # Chmodding because, when building on Windows, files are copied in with
13 # -rwxr-xr-x permissions.
14 #
15 # Copying to a temp location, then moving because chmodding the copied file has
16 # no effect (Docker AUFS-related bug maybe?)
17
18 # Host keys
19 COPY ssh_host_rsa_key /tmp/etc/ssh/ssh_host_rsa_key
20 RUN install -m 0600 /tmp/etc/ssh/ssh_host_rsa_key /etc/ssh/ssh_host_rsa_key
21
22 COPY ssh_host_ecdsa_key /tmp/etc/ssh/ssh_host_ecdsa_key
23 RUN install -m 0600 /tmp/etc/ssh/ssh_host_ecdsa_key /etc/ssh/ssh_host_ecdsa_key
24
25 COPY ssh_host_ed25519_key /tmp/etc/ssh/ssh_host_ed25519_key
26 RUN install -m 0600 /tmp/etc/ssh/ssh_host_ed25519_key /etc/ssh/ssh_host_ed25519_key
27
28 # Trusted CA keys
29 COPY ca_ecdsa /tmp/etc/ssh/ca_ecdsa
30 RUN install -m 0600 /tmp/etc/ssh/ca_ecdsa /etc/ssh/ca_ecdsa
31
32 COPY ca_rsa /tmp/etc/ssh/ca_rsa
33 RUN install -m 0600 /tmp/etc/ssh/ca_rsa /etc/ssh/ca_rsa
34
35 COPY ca_user_keys.pub /tmp/etc/ssh/ca_user_keys.pub
36 RUN install -m 0600 /tmp/etc/ssh/ca_user_keys.pub /etc/ssh/ca_user_keys.pub
37
38 # User
39 RUN adduser --disabled-password --gecos 'Test user for libssh2 integration tests' libssh2
40 RUN echo 'libssh2:my test password' | chpasswd
41
42 # Config
43 RUN sed -i 's/KbdInteractiveAuthentication no/KbdInteractiveAuthentication yes/' /etc/ssh/sshd_config
44 COPY sshd_config /tmp/etc/ssh/sshd_config
45 RUN cat /tmp/etc/ssh/sshd_config >> /etc/ssh/sshd_config
46 RUN echo 'TrustedUserCAKeys /etc/ssh/ca_user_keys.pub' >> /etc/ssh/sshd_config
47
48
49 # SSH login fix. Otherwise user is kicked off after login
50 RUN sed 's/session\s*required\s*pam_loginuid.so/session optional pam_loginuid.so/g' -i /etc/pam.d/sshd
51
52 USER libssh2
53
54 RUN mkdir -p /home/libssh2/.ssh
55 RUN mkdir -p /home/libssh2/sandbox
56
57 COPY authorized_keys /tmp/libssh2/.ssh/authorized_keys
58 RUN install -m 0600 /tmp/libssh2/.ssh/authorized_keys /home/libssh2/.ssh/authorized_keys
59
60 USER root
61
62 EXPOSE 22
63 # -e gives logs via 'docker logs'
64 CMD ["/usr/sbin/sshd", "-D", "-e"]