-
-
Notifications
You must be signed in to change notification settings - Fork 978
Expand file tree
/
Copy pathDockerfile
More file actions
54 lines (50 loc) · 2.37 KB
/
Dockerfile
File metadata and controls
54 lines (50 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
FROM alpine:3.23
COPY --chown=root:root server/ssh /etc/ssh/
COPY --chown=root:root server/script /opt/sshnet
COPY user/sshnet /home/sshnet/.ssh
RUN apk update && apk upgrade --no-cache && \
apk add --no-cache syslog-ng && \
# install and configure sshd
apk add --no-cache openssh && \
# install openssh-server-pam to allow for keyboard-interactive authentication
apk add --no-cache openssh-server-pam && \
# must not use * for dos2unix parameter otherwise it tries to process folders too and fails
dos2unix /etc/ssh/ssh*key && \
chmod 400 /etc/ssh/ssh*key && \
sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config && \
sed -i 's/#LogLevel\s*INFO/LogLevel DEBUG3/' /etc/ssh/sshd_config && \
# Set the default RSA key
echo 'HostKey /etc/ssh/ssh_host_rsa_key' >> /etc/ssh/sshd_config && \
echo 'TrustedUserCAKeys /etc/ssh/user-ca.pub' >> /etc/ssh/sshd_config && \
echo 'RekeyLimit 1M 0' >> /etc/ssh/sshd_config && \
chmod 646 /etc/ssh/sshd_config && \
# install and configure sudo
apk add --no-cache sudo && \
addgroup sudo && \
# allow root to run any command
echo 'root ALL=(ALL) ALL' > /etc/sudoers && \
# allow everyone in the 'sudo' group to run any command without a password
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers && \
# add user to run most of the integration tests
adduser -D sshnet && \
passwd -u sshnet && \
echo 'sshnet:ssh4ever' | chpasswd && \
# must not use * for dos2unix parameter otherwise it tries to process folders too and fails
dos2unix /home/sshnet/.ssh/*_key* && \
chown -R sshnet:sshnet /home/sshnet && \
chmod -R 700 /home/sshnet/.ssh && \
chmod -R 644 /home/sshnet/.ssh/authorized_keys && \
# add user to administer container (update configs, restart sshd)
adduser -D sshnetadm && \
passwd -u sshnetadm && \
echo 'sshnetadm:ssh4ever' | chpasswd && \
addgroup sshnetadm sudo && \
dos2unix /opt/sshnet/* && \
# install shadow package; we use chage command in this package to expire/unexpire password of the sshnet user
apk add --no-cache shadow && \
# allow us to use telnet command; we use this in the remote port forwarding tests
apk --no-cache add busybox-extras && \
# install full-fledged ps command
apk add --no-cache procps
EXPOSE 22 22
ENTRYPOINT ["/opt/sshnet/start.sh"]