Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Syntax3rror404 committed Aug 24, 2024
1 parent 3f5f914 commit 8f33c13
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
9 changes: 0 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,6 @@ RUN addgroup --gid 1001 devgroup && \
adduser --uid 1001 --ingroup devgroup --shell /bin/bash --home /home/dev --disabled-password dev && \
echo "dev ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

# Ensure SSH configuration and host keys are set up
RUN ssh-keygen -A && \
sed -i 's/^#HostKey/HostKey/' /etc/ssh/sshd_config && \
chown -R root:root /etc/ssh && \
chmod 600 /etc/ssh/ssh_host_* && \
echo 'dev:dev' | chpasswd && \
sed -i 's|#PermitRootLogin prohibit-password|PermitRootLogin no|' /etc/ssh/sshd_config && \
sed -i 's|#PasswordAuthentication yes|PasswordAuthentication no|' /etc/ssh/sshd_config

# Adjust permissions for /usr/local and home directories
RUN chown -R dev:devgroup /usr/local /home/dev

Expand Down
17 changes: 12 additions & 5 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
#!/bin/bash

# Ensure SSH host keys are available; generate them if they do not exist
if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then
# Ensure SSH host keys are available and generate them if they do not exist
HOST_KEY_DIR="/home/dev/ssh_keys"
mkdir -p $HOST_KEY_DIR

if [ ! -f $HOST_KEY_DIR/ssh_host_rsa_key ]; then
echo "Generating new SSH host keys."
ssh-keygen -A
ssh-keygen -t rsa -f $HOST_KEY_DIR/ssh_host_rsa_key -N '' >/dev/null
ssh-keygen -t ecdsa -f $HOST_KEY_DIR/ssh_host_ecdsa_key -N '' >/dev/null
ssh-keygen -t ed25519 -f $HOST_KEY_DIR/ssh_host_ed25519_key -N '' >/dev/null
fi

# Start SSH service
/usr/sbin/sshd -D
# Start SSH service with custom host key location
/usr/sbin/sshd -D -o HostKey=$HOST_KEY_DIR/ssh_host_rsa_key \
-o HostKey=$HOST_KEY_DIR/ssh_host_ecdsa_key \
-o HostKey=$HOST_KEY_DIR/ssh_host_ed25519_key

# Check if any additional commands were passed and execute them
if [ "$#" -gt 0 ]; then
Expand Down

0 comments on commit 8f33c13

Please sign in to comment.