privateone commited on
Commit
bd5117d
·
verified ·
1 Parent(s): 03f7770

Create Dockerfile3

Browse files
Files changed (1) hide show
  1. Dockerfile3 +143 -0
Dockerfile3 ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ # Create the 'admin' user with home directory and password, and 'administrator' group
30
+ #RUN useradd -m -s /bin/bash admin && \
31
+ # echo 'admin:password' | chpasswd && \
32
+ # useradd -m -s /bin/bash ubuntu && \
33
+ # echo 'ubuntu:password' | chpasswd && \
34
+ # groupadd administrator && \
35
+ # usermod -aG administrator,sudo admin && \
36
+ # usermod -aG administrator,sudo ubuntu
37
+
38
+ # Create the 'admin' and 'ubuntu' users with home directories and passwords, and add them to the 'sudo' group
39
+ #RUN groupadd -r admin && useradd -r -g users admin && \
40
+ # echo 'admin:password' | chpasswd && \
41
+ # echo 'ubuntu:password' | chpasswd && \
42
+
43
+ RUN useradd -m admin && \
44
+ echo "admin:password" | chpasswd
45
+ # usermod -aG sudo admin && \
46
+ # echo "admin ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
47
+
48
+ #RUN id -u ubuntu &>/dev/null || useradd -m -s /bin/bash ubuntu && \
49
+ # usermod -aG sudo ubuntu && \
50
+ # echo "ubuntu:password" | chpasswd && \
51
+ # echo "ubuntu ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
52
+
53
+ #RUN echo "password" | su - ubuntu -c "whoami"
54
+
55
+ # Copy the application code to the container
56
+ COPY . /app
57
+
58
+ # Create necessary directories and set permissions
59
+ RUN mkdir -p /var/run/sshd /app /app/users/sshs /app/ssh && \
60
+ chmod -R 777 /app
61
+ # chmod -R 777 /home/admin/.ssh && \
62
+ #cp /app/ssh_config /home/admin/.ssh/config
63
+ #touch /etc/sudoers
64
+
65
+ # Grant full sudo access to the 'administrator' group
66
+ #RUN sed -i 's/Defaults !requiretty/Defaults requiretty/' /etc/sudoers && \
67
+ # echo 'admin ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers && \
68
+ # echo 'ubuntu ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
69
+ #RUN echo "%administrator ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
70
+
71
+ # Generate SSH host keys
72
+ #RUN ssh-keygen -A &&\
73
+ # sudo ufw allow 2222/tcp
74
+
75
+ #RUN sudo ufw disable
76
+
77
+ #RUN rm -f /etc/ssh/ssh_host_* && \
78
+ # yes y | ssh-keygen -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -N "" && \
79
+ # yes y | ssh-keygen -t ecdsa -b 256 -f /etc/ssh/ssh_host_ecdsa_key -N "" && \
80
+ # yes y | ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N ""
81
+
82
+
83
+ # Secure SSH Configuration
84
+ #RUN sed -i 's/#PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config && \
85
+ # sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config && \
86
+ # sed -i 's/#ChallengeResponseAuthentication yes/ChallengeResponseAuthentication no/' /etc/ssh/sshd_config && \
87
+ # sed -i 's/#UsePAM yes/UsePAM no/' /etc/ssh/sshd_config && \
88
+ # sed -i 's/#Port 22/Port 2222/' /etc/ssh/sshd_config && \
89
+ # echo "AllowUsers *" >> /etc/ssh/sshd_config && \
90
+ # echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config && \
91
+ # echo "PubkeyAuthentication yes" >> /etc/ssh/sshd_config && \
92
+ # echo "AuthorizedKeysFile .ssh/authorized_keys" >> /etc/ssh/sshd_config && \
93
+
94
+ RUN cp /app/sshd_config /etc/ssh/sshd_config && \
95
+ cat /etc/ssh/sshd_config
96
+
97
+
98
+ # Copy all the contents of /etc/ssh to /app/ssh
99
+ RUN mkdir -p /app/ssh && cp -r /etc/ssh/* /app/ssh
100
+
101
+
102
+ # Set the permissions for the SSH keys
103
+ RUN chmod 777 /etc/ssh/ssh_* && \
104
+ touch /app/ssh/ssh_known_hosts && \
105
+ chmod 777 /app/ssh/ssh_* && \
106
+ chmod 777 /home
107
+
108
+ # List contents of /etc/ssh and /app/ssh
109
+ RUN ls -l /etc/ssh/ && \
110
+ ls -l /app/ssh/
111
+
112
+ # Install WebSSH
113
+ RUN python3 -m venv /app/WebSSHEnv && \
114
+ /app/WebSSHEnv/bin/pip install --no-cache-dir --upgrade pip && \
115
+ /app/WebSSHEnv/bin/pip install --no-cache-dir -r /app/WebSSH/requirements.txt && \
116
+ /app/WebSSHEnv/bin/pip list
117
+
118
+ # Expose the new SSH port
119
+ EXPOSE 2222
120
+
121
+ EXPOSE 7860
122
+
123
+ RUN chmod -R 777 /app
124
+ WORKDIR /home/admin
125
+
126
+ #USER admin
127
+
128
+
129
+ # Generate SSH keys
130
+ #RUN ssh-keygen -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -N "" -y && \
131
+ # ssh-keygen -t ecdsa -b 256 -f /etc/ssh/ssh_host_ecdsa_key -N "" -y && \
132
+ # ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N "" -y
133
+
134
+
135
+ # Copy the start.sh script
136
+ #RUN chmod 777 /app/venv/lib/python3.12/site-packages/
137
+ #RUN touch /app/venv/lib/python3.12/site-packages/known_hosts
138
+ #RUN chmod 777 /app/venv/lib/python3.12/site-packages/known_hosts
139
+
140
+ #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"]
141
+
142
+
143
+ CMD ["/app/start.sh"]