-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
39 lines (31 loc) · 1.1 KB
/
Dockerfile
File metadata and controls
39 lines (31 loc) · 1.1 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
# Use Ubuntu as the base image
FROM ubuntu:latest AS runner
# Set noninteractive mode for apt-get
ENV DEBIAN_FRONTEND=noninteractive
# Install SSH Server and other utilities
RUN apt-get update && \
apt-get install -y \
curl \
net-tools \
openssh-server \
sudo \
vim \
wget \
&& rm -rf /var/lib/apt/lists/*
# Create a user (e.g., 'dev') and set the password
RUN useradd -rm -d /home/dev -s /bin/bash -g root -G sudo -u 1001 dev && \
mkdir -p /home/dev/.ssh && \
chmod 700 /home/dev/.ssh
# SSH login fix. Otherwise, the user is kicked off after login
RUN mkdir /var/run/sshd
# Update SSH settings to restrict authentication to public key only
RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin no/' /etc/ssh/sshd_config && \
sed -i 's/#AllowTcpForwarding no/AllowTcpForwarding yes/' /etc/ssh/sshd_config && \
sed -i 's/#PermitTunnel no/PermitTunnel yes/' /etc/ssh/sshd_config
# Add the custom entrypoint script
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
# Expose the SSH port
EXPOSE 22
# Run the SSH server
ENTRYPOINT [ "/entrypoint.sh" ]