Update Dockerfile
Browse files- Dockerfile +25 -9
Dockerfile
CHANGED
@@ -1,10 +1,26 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
RUN
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
1 |
+
# Use a base image with SSH support, like Ubuntu
|
2 |
+
FROM ubuntu:22.04
|
3 |
+
|
4 |
+
# Update package list and install necessary packages
|
5 |
+
RUN apt-get update && apt-get install -y \
|
6 |
+
openssh-server \
|
7 |
+
sudo \
|
8 |
+
curl \
|
9 |
+
vim \
|
10 |
+
net-tools \
|
11 |
+
&& mkdir /var/run/sshd
|
12 |
+
|
13 |
+
# Create a new user and set a password (modify username and password as needed)
|
14 |
+
RUN useradd -rm -d /home/user -s /bin/bash -g root -G sudo -u 1000 user && \
|
15 |
+
echo 'user:user' | chpasswd && \
|
16 |
+
echo 'user ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
|
17 |
+
|
18 |
+
# Allow root login and password authentication
|
19 |
RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
|
20 |
+
RUN sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config
|
21 |
+
|
22 |
+
# Expose SSH port
|
23 |
+
EXPOSE 7860
|
24 |
+
|
25 |
+
# Start the SSH service when the container starts
|
26 |
+
CMD ["/usr/sbin/sshd", "-D"]
|