Spaces:
Paused
Paused
| # Use the official Ubuntu base image | |
| FROM ubuntu:latest | |
| # Set the maintainer label | |
| LABEL maintainer="your-email@example.com" | |
| # Prevent prompts during package installation | |
| ARG DEBIAN_FRONTEND=noninteractive | |
| #RUN useradd -rm -d /home/ubuntu -s /bin/bash -g root -G sudo -u 1000 ubuntu && \ | |
| # echo 'root:password' | chpasswd | |
| # echo 'ubuntu:ubuntu' | chpasswd && \ | |
| # Copy the application code to the container | |
| COPY . /app | |
| # Install necessary packages | |
| RUN apt update && apt install -y \ | |
| openssh-server \ | |
| openssh\ | |
| sudo \ | |
| bash \ | |
| python3 \ | |
| python3-pip \ | |
| python3-venv \ | |
| net-tools && \ | |
| apt clean && \ | |
| rm -rf /var/lib/apt/lists/* | |
| RUN useradd -ms /bin/bash ubuntu | |
| # SSH Configuration | |
| RUN mkdir -p /var/run/sshd /app /app/ssh | |
| RUN chmod -R 777 /app | |
| # Generate SSH keys | |
| RUN ssh-keygen -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -N "" && \ | |
| ssh-keygen -t ecdsa -b 256 -f /etc/ssh/ssh_host_ecdsa_key -N "" && \ | |
| ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N "" | |
| # Secure SSH Configuration | |
| RUN sed -i 's/#PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config && \ | |
| sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config && \ | |
| sed -i 's/#ChallengeResponseAuthentication yes/ChallengeResponseAuthentication no/' /etc/ssh/sshd_config && \ | |
| sed -i 's/#UsePAM yes/UsePAM no/' /etc/ssh/sshd_config && \ | |
| sed -i 's/#Port 22/Port 2222/' /etc/ssh/sshd_config && \ | |
| echo "AllowUsers admin" >> /etc/ssh/sshd_config | |
| # Copy all the contents of /etc/ssh to /app/ssh | |
| RUN mkdir -p /app/ssh && cp -r /etc/ssh/* /app/ssh | |
| # Set the permissions for the SSH keys | |
| RUN chmod 777 /etc/ssh/ssh_host_* && \ | |
| touch /app/ssh/ssh_known_hosts && \ | |
| chmod 777 /app/ssh/ssh_* && \ | |
| chmod 777 /home | |
| # List contents of /etc/ssh and /app/ssh | |
| RUN ls -l /etc/ssh/ && \ | |
| ls -l /app/ssh/ | |
| # Install WebSSH | |
| RUN python3 -m venv /app/venv && \ | |
| /app/venv/bin/pip install --no-cache-dir --upgrade pip && \ | |
| /app/venv/bin/pip install --no-cache-dir webssh && \ | |
| /app/venv/bin/pip list | |
| # Set the working directory | |
| WORKDIR /app | |
| USER root | |
| # Expose the port the app runs on | |
| EXPOSE 7860 | |
| # Expose the port the app runs on | |
| EXPOSE 2222 | |
| # Define the command to run the application | |
| CMD ["/app/start.sh"] |