-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlocal.Dockerfile
More file actions
34 lines (26 loc) · 1.08 KB
/
local.Dockerfile
File metadata and controls
34 lines (26 loc) · 1.08 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
FROM alpine:3.22 AS sshprep
RUN apk add --no-cache openssh \
&& ssh-keygen -A
FROM runtime as local
USER root
RUN apk add --update --no-cache openssh
# Copy cleanly generated host keys from the pure Alpine stage
COPY --from=sshprep /etc/ssh /etc/ssh
# Your existing setup
RUN mkdir -p /root/.ssh \
&& touch /root/.ssh/authorized_keys \
&& chmod 700 /root/.ssh \
&& chmod 600 /root/.ssh/authorized_keys
COPY id_rsa.pub /root/.ssh/authorized_keys
RUN sed -i '/^AllowTcpForwarding/d' /etc/ssh/sshd_config \
&& sed -i '/^GatewayPorts/d' /etc/ssh/sshd_config \
&& echo "AllowTcpForwarding yes" >> /etc/ssh/sshd_config \
&& echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config \
&& echo 'PermitEmptyPasswords yes' >> /etc/ssh/sshd_config \
&& echo 'PasswordAuthentication yes' >> /etc/ssh/sshd_config \
&& echo 'ChallengeResponseAuthentication no' >> /etc/ssh/sshd_config \
&& echo 'GatewayPorts clientspecified' >> /etc/ssh/sshd_config \
&& sed -i '/UsePAM/d' /etc/ssh/sshd_config
RUN echo 'root:password' | chpasswd
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]