File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -56,15 +56,6 @@ RUN addgroup --gid 1001 devgroup && \
5656 adduser --uid 1001 --ingroup devgroup --shell /bin/bash --home /home/dev --disabled-password dev && \
5757 echo "dev ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
5858
59- # Ensure SSH configuration and host keys are set up
60- RUN ssh-keygen -A && \
61- sed -i 's/^#HostKey/HostKey/' /etc/ssh/sshd_config && \
62- chown -R root:root /etc/ssh && \
63- chmod 600 /etc/ssh/ssh_host_* && \
64- echo 'dev:dev' | chpasswd && \
65- sed -i 's|#PermitRootLogin prohibit-password|PermitRootLogin no|' /etc/ssh/sshd_config && \
66- sed -i 's|#PasswordAuthentication yes|PasswordAuthentication no|' /etc/ssh/sshd_config
67-
6859# Adjust permissions for /usr/local and home directories
6960RUN chown -R dev:devgroup /usr/local /home/dev
7061
Original file line number Diff line number Diff line change 11#! /bin/bash
22
3- # Ensure SSH host keys are available; generate them if they do not exist
4- if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then
3+ # Ensure SSH host keys are available and generate them if they do not exist
4+ HOST_KEY_DIR=" /home/dev/ssh_keys"
5+ mkdir -p $HOST_KEY_DIR
6+
7+ if [ ! -f $HOST_KEY_DIR /ssh_host_rsa_key ]; then
58 echo " Generating new SSH host keys."
6- ssh-keygen -A
9+ ssh-keygen -t rsa -f $HOST_KEY_DIR /ssh_host_rsa_key -N ' ' > /dev/null
10+ ssh-keygen -t ecdsa -f $HOST_KEY_DIR /ssh_host_ecdsa_key -N ' ' > /dev/null
11+ ssh-keygen -t ed25519 -f $HOST_KEY_DIR /ssh_host_ed25519_key -N ' ' > /dev/null
712fi
813
9- # Start SSH service
10- /usr/sbin/sshd -D
14+ # Start SSH service with custom host key location
15+ /usr/sbin/sshd -D -o HostKey=$HOST_KEY_DIR /ssh_host_rsa_key \
16+ -o HostKey=$HOST_KEY_DIR /ssh_host_ecdsa_key \
17+ -o HostKey=$HOST_KEY_DIR /ssh_host_ed25519_key
1118
1219# Check if any additional commands were passed and execute them
1320if [ " $# " -gt 0 ]; then
You can’t perform that action at this time.
0 commit comments