privateone commited on
Commit
fd7bb97
·
verified ·
1 Parent(s): 0a622ca

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +126 -0
Dockerfile ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use the latest Ubuntu image
2
+ FROM ubuntu:focal
3
+
4
+ # Set environment variable to avoid interactive prompts
5
+ ENV DEBIAN_FRONTEND=noninteractive
6
+
7
+ # Set timezone to your desired timezone (e.g., "America/New_York")
8
+ #RUN ln -fs /usr/share/zoneinfo/America/New_York /etc/localtime && \
9
+ # echo "India/Kolkata" > /etc/timezone
10
+
11
+ # Update package list, install required packages, and clean up
12
+ RUN apt-get update && \
13
+ apt-get install -y \
14
+ ufw\
15
+ sudo\
16
+ bash \
17
+ passwd\
18
+ sshpass\
19
+ python3\
20
+ keychain\
21
+ net-tools\
22
+ python3-pip\
23
+ python3-venv\
24
+ openssh-server &&\
25
+ apt clean && \
26
+ apt-get clean && \
27
+ rm -rf /var/lib/apt/lists/*
28
+
29
+
30
+
31
+ RUN useradd -m -u 1000 admin && \
32
+ echo "admin:password" | chpasswd &&\
33
+ usermod -aG sudo admin && \
34
+ echo "admin ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
35
+
36
+ COPY . /app
37
+
38
+ # Generate SSH host keys
39
+ #RUN ssh-keygen -A &&\
40
+ # sudo ufw allow 2222/tcp
41
+
42
+ #RUN sudo ufw disable
43
+ #RUN cp /app/sshd_config /etc/ssh/sshd_config # && cat /etc/ssh/sshd_config
44
+
45
+ #RUN chmod -R 755 /etc/ssh/* &&\
46
+ # rm -f /etc/ssh/ssh_host_rsa_* && \
47
+ # rm -f /etc/ssh/ssh_host_ecdsa_* && \
48
+ # rm -f /etc/ssh/ssh_host_ed25519_* && \
49
+ # rm -f /etc/ssh/ssh_known_* && \
50
+ # touch /etc/ssh/ssh_known_hosts
51
+
52
+ RUN echo " Public Key $(cat /etc/ssh/ssh_host_rsa_key.pub)" && \
53
+ echo " Private Key $(cat /etc/ssh/ssh_host_rsa_key)"
54
+
55
+
56
+
57
+ #RUN yes y | ssh-keygen -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -N "" && \
58
+ # yes y | ssh-keygen -t ecdsa -b 256 -f /etc/ssh/ssh_host_ecdsa_key -N "" && \
59
+ # yes y | ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N "" && \
60
+ # ssh-keygen -Hf /etc/ssh/ssh_known_hosts && \
61
+ # chmod -R 755 /etc/ssh/* && \
62
+ # echo " Public Key $(cat /etc/ssh/ssh_host_rsa_key.pub)" && \
63
+ # echo " Private Key $(cat /etc/ssh/ssh_host_rsa_key)"
64
+
65
+ #ssh-keyscan -p 2222 0.0.0.0 >> /etc/ssh/ssh_known_hosts
66
+
67
+
68
+ # Secure SSH Configuration
69
+ #RUN sed -i 's/#PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config && \
70
+ # sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config && \
71
+ # sed -i 's/#ChallengeResponseAuthentication yes/ChallengeResponseAuthentication no/' /etc/ssh/sshd_config && \
72
+ # sed -i 's/#UsePAM yes/UsePAM no/' /etc/ssh/sshd_config && \
73
+ # sed -i 's/#Port 22/Port 2222/' /etc/ssh/sshd_config && \
74
+ # echo "AllowUsers *" >> /etc/ssh/sshd_config && \
75
+ # echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config && \
76
+ # echo "PubkeyAuthentication yes" >> /etc/ssh/sshd_config && \
77
+ # echo "AuthorizedKeysFile .ssh/authorized_keys" >> /etc/ssh/sshd_config && \
78
+
79
+
80
+
81
+ # Copy all the contents of /etc/ssh to /app/ssh
82
+ #RUN mkdir -p /app/ssh && cp -r /etc/ssh/* /app/ssh
83
+
84
+
85
+ # Set the permissions for the SSH keys
86
+ #RUN chmod 777 /etc/ssh/ssh_* && \
87
+ # touch /app/ssh/ssh_known_hosts && \
88
+ # chmod 777 /app/ssh/ssh_* && \
89
+ # chmod 777 /home
90
+
91
+ # List contents of /etc/ssh and /app/ssh
92
+ RUN ls -la /etc/ssh/ # && ls -l /app/ssh/
93
+
94
+ # Install WebSSH
95
+ RUN python3 -m venv /app/WebSSHEnv && \
96
+ /app/WebSSHEnv/bin/pip install --no-cache-dir --upgrade pip && \
97
+ /app/WebSSHEnv/bin/pip install --no-cache-dir -r /app/WebSSH/requirements.txt && \
98
+ /app/WebSSHEnv/bin/pip list
99
+
100
+ # Expose the new SSH port
101
+ EXPOSE 2222
102
+
103
+ EXPOSE 7860
104
+
105
+ RUN chmod -R 777 /app && \
106
+ echo "* Changing User to Admin :$(echo "password" || su - admin)" &&\
107
+ echo "* Current User WHO AM I $(whoami)"
108
+
109
+ USER admin
110
+ #WORKDIR /home/admin
111
+
112
+ # Generate SSH keys
113
+ #RUN ssh-keygen -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -N "" -y && \
114
+ # ssh-keygen -t ecdsa -b 256 -f /etc/ssh/ssh_host_ecdsa_key -N "" -y && \
115
+ # ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N "" -y
116
+
117
+
118
+ # Copy the start.sh script
119
+ #RUN chmod 777 /app/venv/lib/python3.12/site-packages/
120
+ #RUN touch /app/venv/lib/python3.12/site-packages/known_hosts
121
+ #RUN chmod 777 /app/venv/lib/python3.12/site-packages/known_hosts
122
+
123
+ #CMD [ "/usr/sbin/sshd -p 2222 &&","source /app/venv/bin/activate &&","wssh --address='0.0.0.0' --port=7860 --xsrf=False --debug=True --maxconn=4 --policy=autoadd"]
124
+
125
+
126
+ ENTRYPOINT ["/app/start.sh"]