FROM ubuntu:latest
# Install OpenSSH Server and create necessary directory
RUN apt-get update && apt-get install -y openssh-server && \
mkdir /var/run/sshd
# Set a password for the root user (change 'your_password' to a secure one)
RUN echo 'root:your_password' | chpasswd
# Modify SSH config to allow root login with password and fix PAM issue
RUN sed -i 's/^#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \
sed 's@session\\s*required\\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
# Expose port 22
EXPOSE 22
# Start SSH server in detached mode
CMD ["/usr/sbin/sshd", "-D"]