#!/bin/bash
touch /var/log/auth.log
touch /var/log/apache2/access.log
touch /var/log/apache2/error.log
# Starting SSH service
service ssh start
tail -F /var/log/apache2/* /var/log/auth.log &
service apache2 restart
# Run Apache2 in the foreground is important
apache2ctl -D FOREGROUND
Теперь, когда я запускаю Docker-контейнер и пытаюсь зайти в браузер и получить доступ к http://localhost:8080, он не запрашивает у меня имя пользователя и пароль, а также я могу git clone git repo без аутентификации, это можно исправить. Ваша помощь будет оценена по достоинству
# Set up SSH access RUN mkdir /var/run/sshd RUN echo 'root:root' | chpasswd RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config RUN sed -ri 's/^#?PasswordAuthentication\s+.*/PasswordAuthentication yes/' /etc/ssh/sshd_config RUN sed -ri 's/^#?PermitRootLogin\s+.*/PermitRootLogin yes/' /etc/ssh/sshd_config RUN sed -ri 's/^#?ChallengeResponseAuthentication\s+.*/ChallengeResponseAuthentication no/' /etc/ssh/sshd_config
# Add SSH public key to root's authorized keys RUN mkdir /root/.ssh && \ echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEHAtto0bVGTAUATJhiDTjKa/lZg1LYu+gdJcyn4cK8D local" > /root/.ssh/authorized_keys && \ chmod 600 /root/.ssh/authorized_keys
# Enable Apache SSL and CGI modules RUN a2enmod ssl && \ a2enmod cgi && \ a2ensite default-ssl # Enable the default SSL site configuration
# Set up Apache to serve the Git repository RUN mkdir /var/www/git && \ git init --bare /var/www/git/test.git && \ chown -R www-data:www-data /var/www/git
# Enable the site and ensure the Apache user can read the .htpasswd file RUN a2ensite 000-default && \ chmod 644 /auth/.htpasswd && \ chown www-data:www-data /auth/.htpasswd
# Expose port 22 for SSH access, 80 for HTTP access, and 443 for HTTPS access EXPOSE 22 80 443
# Copy the start script into the container and set permissions COPY start.sh /start.sh RUN chmod +x /start.sh
# Command to run the startup script CMD ["/start.sh"] [/code] Это start.sh [code]#!/bin/bash touch /var/log/auth.log touch /var/log/apache2/access.log touch /var/log/apache2/error.log # Starting SSH service service ssh start tail -F /var/log/apache2/* /var/log/auth.log &
service apache2 restart
# Run Apache2 in the foreground is important apache2ctl -D FOREGROUND [/code] Теперь, когда я запускаю Docker-контейнер и пытаюсь зайти в браузер и получить доступ к http://localhost:8080, он не запрашивает у меня имя пользователя и пароль, а также я могу git clone git repo без аутентификации, это можно исправить. Ваша помощь будет оценена по достоинству