Spaces:
Paused
Paused
Update Dockerfile
Browse files- Dockerfile +34 -53
Dockerfile
CHANGED
|
@@ -69,72 +69,53 @@ RUN sed -i 's/Defaults !requiretty/Defaults requiretty/' /etc/sudoers && \
|
|
| 69 |
# sudo ufw allow 2222/tcp
|
| 70 |
|
| 71 |
# Generate SSH keys
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
|
| 76 |
-
RUN ssh-keygen -q -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -N "" -y && \
|
| 77 |
-
ssh-keygen -q -t ecdsa -b 256 -f /etc/ssh/ssh_host_ecdsa_key -N "" -y && \
|
| 78 |
-
ssh-keygen -q -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N "" -y
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \
|
| 83 |
sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config && \
|
| 84 |
sed -i 's/#ChallengeResponseAuthentication yes/ChallengeResponseAuthentication no/' /etc/ssh/sshd_config && \
|
| 85 |
-
sed -i 's/#UserKnownHostsFile.*/UserKnownHostsFile \/app\/ssh\/ssh_known_hosts/' /etc/ssh/sshd_config && \
|
| 86 |
sed -i 's/#UsePAM yes/UsePAM no/' /etc/ssh/sshd_config && \
|
| 87 |
sed -i 's/#Port 22/Port 2222/' /etc/ssh/sshd_config && \
|
| 88 |
-
echo "AllowUsers
|
|
|
|
| 89 |
|
| 90 |
-
# Copy
|
| 91 |
-
RUN cp -r /etc/ssh/* /app/ssh
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
| 93 |
touch /app/ssh/ssh_known_hosts && \
|
| 94 |
-
chmod 777 /app/ssh/
|
|
|
|
| 95 |
|
| 96 |
# List contents of /etc/ssh and /app/ssh
|
| 97 |
RUN ls -l /etc/ssh/ && \
|
| 98 |
ls -l /app/ssh/
|
| 99 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
|
| 101 |
-
|
| 102 |
-
#RUN groupadd -f administrator && \
|
| 103 |
-
# id -u admin >/dev/null 2>&1 || useradd -m -s /bin/bash -G administrator,sudo admin && \
|
| 104 |
-
# echo 'admin:password' | chpasswd && \
|
| 105 |
-
# echo "%administrator ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
|
| 106 |
-
|
| 107 |
-
# Install WebSSH dependencies
|
| 108 |
-
RUN python3 -m venv /app/WebSSHEnv && \
|
| 109 |
-
/app/WebSSHEnv/bin/pip install --no-cache-dir --upgrade pip && \
|
| 110 |
-
/app/WebSSHEnv/bin/pip install --no-cache-dir webssh && \
|
| 111 |
-
/app/WebSSHEnv/bin/pip list
|
| 112 |
-
|
| 113 |
-
# Change ownership of /home/admin directory
|
| 114 |
-
#RUN chown -R admin:admin /home/admin
|
| 115 |
-
|
| 116 |
-
# Set working directory
|
| 117 |
-
#WORKDIR /app
|
| 118 |
-
|
| 119 |
-
# Expose necessary ports
|
| 120 |
-
EXPOSE 7860 2222
|
| 121 |
-
|
| 122 |
-
# Switch to 'admin' user and set working directory
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
#WORKDIR /home/admin
|
| 126 |
-
# Change ownership of /home/admin directory
|
| 127 |
-
#RUN chown -R admin:admin /home/admin
|
| 128 |
-
#RUN cat /etc/passwd && \
|
| 129 |
-
# cat /etc/group && \
|
| 130 |
-
# cat /etc/sudoers && \
|
| 131 |
-
# cat /etc/shadow
|
| 132 |
-
|
| 133 |
|
| 134 |
-
|
| 135 |
-
#
|
|
|
|
|
|
|
| 136 |
|
| 137 |
-
|
| 138 |
|
| 139 |
-
|
| 140 |
-
CMD ["/app/start.sh"]
|
|
|
|
| 69 |
# sudo ufw allow 2222/tcp
|
| 70 |
|
| 71 |
# Generate SSH keys
|
| 72 |
+
RUN ssh-keygen -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -N "" && \
|
| 73 |
+
ssh-keygen -t ecdsa -b 256 -f /etc/ssh/ssh_host_ecdsa_key -N "" && \
|
| 74 |
+
ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N ""
|
| 75 |
|
| 76 |
+
#RUN ssh-keygen -q -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -N "" -y && \
|
| 77 |
+
# ssh-keygen -q -t ecdsa -b 256 -f /etc/ssh/ssh_host_ecdsa_key -N "" -y && \
|
| 78 |
+
# ssh-keygen -q -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N "" -y
|
| 79 |
+
|
| 80 |
+
# Secure SSH Configuration
|
| 81 |
+
RUN sed -i 's/#PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config && \
|
|
|
|
| 82 |
sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config && \
|
| 83 |
sed -i 's/#ChallengeResponseAuthentication yes/ChallengeResponseAuthentication no/' /etc/ssh/sshd_config && \
|
|
|
|
| 84 |
sed -i 's/#UsePAM yes/UsePAM no/' /etc/ssh/sshd_config && \
|
| 85 |
sed -i 's/#Port 22/Port 2222/' /etc/ssh/sshd_config && \
|
| 86 |
+
echo "AllowUsers admin" >> /etc/ssh/sshd_config
|
| 87 |
+
|
| 88 |
|
| 89 |
+
# Copy all the contents of /etc/ssh to /app/ssh
|
| 90 |
+
RUN mkdir -p /app/ssh && cp -r /etc/ssh/* /app/ssh
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
# Set the permissions for the SSH keys
|
| 94 |
+
RUN chmod 777 /etc/ssh/ssh_host_* && \
|
| 95 |
touch /app/ssh/ssh_known_hosts && \
|
| 96 |
+
chmod 777 /app/ssh/ssh_* && \
|
| 97 |
+
chmod 777 /home
|
| 98 |
|
| 99 |
# List contents of /etc/ssh and /app/ssh
|
| 100 |
RUN ls -l /etc/ssh/ && \
|
| 101 |
ls -l /app/ssh/
|
| 102 |
|
| 103 |
+
# Install WebSSH
|
| 104 |
+
RUN python3 -m venv /app/venv && \
|
| 105 |
+
/app/venv/bin/pip install --no-cache-dir --upgrade pip && \
|
| 106 |
+
/app/venv/bin/pip install --no-cache-dir -r /app/WebSSH/requirements.txt && \
|
| 107 |
+
/app/venv/bin/pip list
|
| 108 |
+
|
| 109 |
+
# Expose the new SSH port
|
| 110 |
+
EXPOSE 2222
|
| 111 |
|
| 112 |
+
RUN chmod -R 777 /app
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
|
| 114 |
+
# Copy the start.sh script
|
| 115 |
+
#RUN chmod 777 /app/venv/lib/python3.12/site-packages/
|
| 116 |
+
#RUN touch /app/venv/lib/python3.12/site-packages/known_hosts
|
| 117 |
+
#RUN chmod 777 /app/venv/lib/python3.12/site-packages/known_hosts
|
| 118 |
|
| 119 |
+
EXPOSE 7860
|
| 120 |
|
| 121 |
+
CMD ["/app/start.sh"]
|
|
|