Spaces:
Paused
Paused
BinaryONe
commited on
Commit
·
15d9364
1
Parent(s):
a08176f
Changes
Browse files- Dockerfile +17 -76
- Dockerfile1 +83 -0
Dockerfile
CHANGED
|
@@ -1,83 +1,24 @@
|
|
| 1 |
-
# Use the
|
| 2 |
FROM ubuntu:latest
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
ARG DEBIAN_FRONTEND=noninteractive
|
| 9 |
-
|
| 10 |
-
#RUN useradd -rm -d /home/ubuntu -s /bin/bash -g root -G sudo -u 1000 ubuntu && \
|
| 11 |
-
# echo 'root:password' | chpasswd
|
| 12 |
-
# echo 'ubuntu:ubuntu' | chpasswd && \
|
| 13 |
-
|
| 14 |
-
# Copy the application code to the container
|
| 15 |
-
COPY . /app
|
| 16 |
-
|
| 17 |
-
# Install necessary packages
|
| 18 |
-
RUN apt update && apt install -y \
|
| 19 |
-
openssh-server \
|
| 20 |
-
openssh\
|
| 21 |
-
sudo \
|
| 22 |
-
bash \
|
| 23 |
-
python3 \
|
| 24 |
-
python3-pip \
|
| 25 |
-
python3-venv \
|
| 26 |
-
net-tools && \
|
| 27 |
-
apt clean && \
|
| 28 |
rm -rf /var/lib/apt/lists/*
|
| 29 |
|
| 30 |
-
|
| 31 |
-
RUN useradd -
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
RUN chmod -R 777 /app
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
# Generate SSH keys
|
| 39 |
-
RUN ssh-keygen -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -N "" && \
|
| 40 |
-
ssh-keygen -t ecdsa -b 256 -f /etc/ssh/ssh_host_ecdsa_key -N "" && \
|
| 41 |
-
ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N ""
|
| 42 |
-
|
| 43 |
-
# Secure SSH Configuration
|
| 44 |
-
RUN sed -i 's/#PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config && \
|
| 45 |
-
sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config && \
|
| 46 |
-
sed -i 's/#ChallengeResponseAuthentication yes/ChallengeResponseAuthentication no/' /etc/ssh/sshd_config && \
|
| 47 |
-
sed -i 's/#UsePAM yes/UsePAM no/' /etc/ssh/sshd_config && \
|
| 48 |
-
sed -i 's/#Port 22/Port 2222/' /etc/ssh/sshd_config && \
|
| 49 |
-
echo "AllowUsers admin" >> /etc/ssh/sshd_config
|
| 50 |
-
|
| 51 |
-
# Copy all the contents of /etc/ssh to /app/ssh
|
| 52 |
-
RUN mkdir -p /app/ssh && cp -r /etc/ssh/* /app/ssh
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
# Set the permissions for the SSH keys
|
| 56 |
-
RUN chmod 777 /etc/ssh/ssh_host_* && \
|
| 57 |
-
touch /app/ssh/ssh_known_hosts && \
|
| 58 |
-
chmod 777 /app/ssh/ssh_* && \
|
| 59 |
-
chmod 777 /home
|
| 60 |
-
|
| 61 |
-
# List contents of /etc/ssh and /app/ssh
|
| 62 |
-
RUN ls -l /etc/ssh/ && \
|
| 63 |
-
ls -l /app/ssh/
|
| 64 |
-
|
| 65 |
-
# Install WebSSH
|
| 66 |
-
#RUN python3 -m venv /app/venv && \
|
| 67 |
-
RUN pip install --no-cache-dir --upgrade pip && \
|
| 68 |
-
pip install --no-cache-dir -r /app/WebSSH/requirements.txt && \
|
| 69 |
-
pip list
|
| 70 |
-
|
| 71 |
-
# Set the working directory
|
| 72 |
-
WORKDIR /app
|
| 73 |
-
|
| 74 |
-
USER root
|
| 75 |
|
| 76 |
-
#
|
| 77 |
-
|
| 78 |
|
| 79 |
-
#
|
| 80 |
-
|
|
|
|
| 81 |
|
| 82 |
-
#
|
| 83 |
-
CMD ["
|
|
|
|
| 1 |
+
# Use the latest Ubuntu image
|
| 2 |
FROM ubuntu:latest
|
| 3 |
|
| 4 |
+
# Update package list, install required packages, and clean up
|
| 5 |
+
RUN apt-get update && \
|
| 6 |
+
apt-get install -y sudo passwd && \
|
| 7 |
+
apt-get clean && \
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
rm -rf /var/lib/apt/lists/*
|
| 9 |
|
| 10 |
+
# Create the 'admin' user with home directory and password, and 'administrator' group
|
| 11 |
+
RUN useradd -m -s /bin/bash admin && \
|
| 12 |
+
echo 'admin:password' | chpasswd &&\
|
| 13 |
+
groupadd administrator && \
|
| 14 |
+
usermod -aG administrator,sudo admin
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
+
# Grant full sudo access to the 'administrator' group
|
| 17 |
+
RUN echo "%administrator ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
|
| 18 |
|
| 19 |
+
# Switch to 'admin' user and set working directory
|
| 20 |
+
USER admin
|
| 21 |
+
WORKDIR /home/admin
|
| 22 |
|
| 23 |
+
# Default command to keep the container running
|
| 24 |
+
CMD ["bash"]
|
Dockerfile1
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use the official Ubuntu base image
|
| 2 |
+
FROM ubuntu:latest
|
| 3 |
+
|
| 4 |
+
# Set the maintainer label
|
| 5 |
+
LABEL maintainer="your-email@example.com"
|
| 6 |
+
|
| 7 |
+
# Prevent prompts during package installation
|
| 8 |
+
ARG DEBIAN_FRONTEND=noninteractive
|
| 9 |
+
|
| 10 |
+
#RUN useradd -rm -d /home/ubuntu -s /bin/bash -g root -G sudo -u 1000 ubuntu && \
|
| 11 |
+
# echo 'root:password' | chpasswd
|
| 12 |
+
# echo 'ubuntu:ubuntu' | chpasswd && \
|
| 13 |
+
|
| 14 |
+
# Copy the application code to the container
|
| 15 |
+
COPY . /app
|
| 16 |
+
|
| 17 |
+
# Install necessary packages
|
| 18 |
+
RUN apt update && apt install -y \
|
| 19 |
+
openssh-server \
|
| 20 |
+
openssh\
|
| 21 |
+
sudo \
|
| 22 |
+
bash \
|
| 23 |
+
python3 \
|
| 24 |
+
python3-pip \
|
| 25 |
+
python3-venv \
|
| 26 |
+
net-tools && \
|
| 27 |
+
apt clean && \
|
| 28 |
+
rm -rf /var/lib/apt/lists/*
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
RUN useradd -ms /bin/bash ubuntu
|
| 32 |
+
|
| 33 |
+
# SSH Configuration
|
| 34 |
+
RUN mkdir -p /var/run/sshd /app /app/ssh
|
| 35 |
+
RUN chmod -R 777 /app
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
# Generate SSH keys
|
| 39 |
+
RUN ssh-keygen -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -N "" && \
|
| 40 |
+
ssh-keygen -t ecdsa -b 256 -f /etc/ssh/ssh_host_ecdsa_key -N "" && \
|
| 41 |
+
ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N ""
|
| 42 |
+
|
| 43 |
+
# Secure SSH Configuration
|
| 44 |
+
RUN sed -i 's/#PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config && \
|
| 45 |
+
sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config && \
|
| 46 |
+
sed -i 's/#ChallengeResponseAuthentication yes/ChallengeResponseAuthentication no/' /etc/ssh/sshd_config && \
|
| 47 |
+
sed -i 's/#UsePAM yes/UsePAM no/' /etc/ssh/sshd_config && \
|
| 48 |
+
sed -i 's/#Port 22/Port 2222/' /etc/ssh/sshd_config && \
|
| 49 |
+
echo "AllowUsers admin" >> /etc/ssh/sshd_config
|
| 50 |
+
|
| 51 |
+
# Copy all the contents of /etc/ssh to /app/ssh
|
| 52 |
+
RUN mkdir -p /app/ssh && cp -r /etc/ssh/* /app/ssh
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
# Set the permissions for the SSH keys
|
| 56 |
+
RUN chmod 777 /etc/ssh/ssh_host_* && \
|
| 57 |
+
touch /app/ssh/ssh_known_hosts && \
|
| 58 |
+
chmod 777 /app/ssh/ssh_* && \
|
| 59 |
+
chmod 777 /home
|
| 60 |
+
|
| 61 |
+
# List contents of /etc/ssh and /app/ssh
|
| 62 |
+
RUN ls -l /etc/ssh/ && \
|
| 63 |
+
ls -l /app/ssh/
|
| 64 |
+
|
| 65 |
+
# Install WebSSH
|
| 66 |
+
#RUN python3 -m venv /app/venv && \
|
| 67 |
+
RUN pip install --no-cache-dir --upgrade pip && \
|
| 68 |
+
pip install --no-cache-dir -r /app/WebSSH/requirements.txt && \
|
| 69 |
+
pip list
|
| 70 |
+
|
| 71 |
+
# Set the working directory
|
| 72 |
+
WORKDIR /app
|
| 73 |
+
|
| 74 |
+
USER root
|
| 75 |
+
|
| 76 |
+
# Expose the port the app runs on
|
| 77 |
+
EXPOSE 7860
|
| 78 |
+
|
| 79 |
+
# Expose the port the app runs on
|
| 80 |
+
EXPOSE 2222
|
| 81 |
+
|
| 82 |
+
# Define the command to run the application
|
| 83 |
+
CMD ["/app/start.sh"]
|