BinaryONe commited on
Commit
3d12fd6
·
1 Parent(s): 3ea2a08
Files changed (1) hide show
  1. Dockerfile +42 -1
Dockerfile CHANGED
@@ -28,9 +28,50 @@ RUN echo "%administrator ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
28
  # Copy the application code to the container
29
  COPY . /app
30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  # Switch to 'admin' user and set working directory
32
  USER admin
33
  WORKDIR /home/admin
34
 
35
  # Default command to keep the container running
36
- CMD ["bash"]
 
28
  # Copy the application code to the container
29
  COPY . /app
30
 
31
+ # Create necessary directories and set permissions
32
+ RUN mkdir -p /var/run/sshd /app /app/ssh && chmod -R 777 /app
33
+
34
+ # Generate SSH host keys
35
+ RUN ssh-keygen -A
36
+
37
+ # Secure SSH configuration
38
+ RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin no/' /etc/ssh/sshd_config && \
39
+ sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config && \
40
+ sed -i 's/#ChallengeResponseAuthentication yes/ChallengeResponseAuthentication no/' /etc/ssh/sshd_config && \
41
+ sed -i 's/#UsePAM yes/UsePAM no/' /etc/ssh/sshd_config && \
42
+ sed -i 's/#Port 22/Port 2222/' /etc/ssh/sshd_config && \
43
+ echo "AllowUsers admin" >> /etc/ssh/sshd_config
44
+
45
+ # Copy SSH keys to /app/ssh and set permissions
46
+ RUN cp -r /etc/ssh/* /app/ssh && \
47
+ chmod -R 777 /etc/ssh/* /app/ssh/* && \
48
+ touch /app/ssh/ssh_known_hosts && chmod 777 /app/ssh/ssh_known_hosts
49
+
50
+ # List contents of /etc/ssh and /app/ssh
51
+ RUN ls -l /etc/ssh/ && \
52
+ ls -l /app/ssh/
53
+
54
+
55
+ # Create an admin user with the administrator group and full permissions
56
+ RUN groupadd administrator && \
57
+ useradd -m -s /bin/bash -G administrator,sudo admin && \
58
+ echo 'admin:password' | chpasswd && \
59
+ echo "%administrator ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
60
+
61
+ # Install WebSSH dependencies
62
+ #RUN python3 -m venv /app/venv && \
63
+ RUN pip install --no-cache-dir --upgrade pip && \
64
+ pip install --no-cache-dir -r /app/WebSSH/requirements.txt
65
+
66
+ # Set working directory
67
+ WORKDIR /app
68
+
69
+ # Expose necessary ports
70
+ EXPOSE 7860 2222
71
+
72
  # Switch to 'admin' user and set working directory
73
  USER admin
74
  WORKDIR /home/admin
75
 
76
  # Default command to keep the container running
77
+ CMD ["/app/start.sh"]