File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# Use Ubuntu as the base image
22FROM ubuntu:latest AS runner
33
4- # Install SSH Server
4+ # Set noninteractive mode for apt-get
5+ ENV DEBIAN_FRONTEND=noninteractive
6+
7+ # Install SSH Server and other utilities
58RUN apt-get update && \
69 apt-get install -y \
10+ curl \
11+ net-tools \
712 openssh-server \
813 sudo \
914 vim \
10- curl \
1115 wget \
12- net-tools \
1316 && rm -rf /var/lib/apt/lists/*
1417
1518# Create a user (e.g., 'dev') and set the password
16- RUN useradd -rm -d /home/dev -s /bin/bash -g root -G sudo -u 1001 dev
19+ RUN useradd -rm -d /home/dev -s /bin/bash -g root -G sudo -u 1001 dev && \
20+ mkdir -p /home/dev/.ssh && \
21+ chmod 700 /home/dev/.ssh
1722
1823# SSH login fix. Otherwise, the user is kicked off after login
1924RUN mkdir /var/run/sshd
2025
21- # Change SSH settings to allow port forwarding
22- RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes /' /etc/ssh/sshd_config && \
26+ # Update SSH settings to restrict authentication to public key only
27+ RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin no /' /etc/ssh/sshd_config && \
2328 sed -i 's/#AllowTcpForwarding no/AllowTcpForwarding yes/' /etc/ssh/sshd_config && \
2429 sed -i 's/#PermitTunnel no/PermitTunnel yes/' /etc/ssh/sshd_config
2530
31+ # Add the custom entrypoint script
2632COPY entrypoint.sh /entrypoint.sh
2733RUN chmod +x /entrypoint.sh
2834
Original file line number Diff line number Diff line change 11#! /bin/bash
22
3- echo " Setting SSH password"
4- echo " dev:${DEV_TUNNEL_SSH_PASSWORD} " | chpasswd
3+ # Set SSH password if the environment variable is defined
4+ if [ -n " ${DEV_TUNNEL_SSH_PASSWORD} " ]; then
5+ echo " Setting SSH password for dev user"
6+ echo " dev:${DEV_TUNNEL_SSH_PASSWORD} " | chpasswd
7+ fi
58
69# Start SSH service
710echo " Starting SSH service"
8- /usr/sbin/sshd -D
11+ /usr/sbin/sshd -D
You can’t perform that action at this time.
0 commit comments