Spaces:
Paused
Paused
File size: 4,162 Bytes
15d9364 ca1110e d89b239 68f28c1 15d9364 2c76eb6 3ea2a08 2c76eb6 b2741c4 3ea2a08 2c76eb6 b2741c4 3ea2a08 2c76eb6 15d9364 d89b239 15d9364 cb46931 2f12044 d89b239 8c7e4ad 2f12044 cc46073 e174d37 c7d3881 4586002 c7d3881 4586002 d89b239 2c76eb6 3d12fd6 967b751 19a162c 6eaf352 e69d427 3d12fd6 19a162c 6eaf352 3d12fd6 6786cf8 19a162c 3d12fd6 b9ead11 cb46931 284c6f8 3d12fd6 1671103 3d12fd6 15d9364 98930dc 284c6f8 1a4023b db27f7e 284c6f8 ca1110e 2f12044 98930dc 105939e 2f12044 7163fa2 15d9364 ab00e2c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | # Use the latest Ubuntu image
FROM ubuntu:focal
# Set environment variable to avoid interactive prompts
ENV DEBIAN_FRONTEND=noninteractive
# Set timezone to your desired timezone (e.g., "America/New_York")
RUN ln -fs /usr/share/zoneinfo/America/New_York /etc/localtime && \
echo "India/Kolkata" > /etc/timezone
# Update package list, install required packages, and clean up
RUN apt-get update && \
apt-get install -y \
sudo\
bash \
expect\
passwd \
python3 \
net-tools\
python3-pip\
python3-venv\
openssh-server &&\
apt clean && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Create the 'admin' user with home directory and password, and 'administrator' group
#RUN useradd -m -s /bin/bash admin && \
# echo 'admin:password' | chpasswd && \
# useradd -m -s /bin/bash ubuntu && \
# echo 'ubuntu:password' | chpasswd && \
# groupadd administrator && \
# usermod -aG administrator,sudo admin && \
# usermod -aG administrator,sudo ubuntu
# Create the 'admin' and 'ubuntu' users with home directories and passwords, and add them to the 'sudo' group
#RUN groupadd -r admin && useradd -r -g users admin && \
# echo 'admin:password' | chpasswd && \
# echo 'ubuntu:password' | chpasswd && \
RUN useradd -m -s /bin/bash admin && \
usermod -aG sudo admin && \
echo "admin:password" | sudo chpasswd && \
echo "admin ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
#RUN id -u ubuntu &>/dev/null || useradd -m -s /bin/bash ubuntu && \
# usermod -aG sudo ubuntu && \
# echo "ubuntu:password" | chpasswd && \
# echo "ubuntu ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
#RUN echo "password" | su - ubuntu -c "whoami"
# Copy the application code to the container
COPY . /app
# Create necessary directories and set permissions
RUN mkdir -p /var/run/sshd /app /app/users/sshs /app/ssh && \
chmod -R 777 /app
# touch /etc/sudoers
# Grant full sudo access to the 'administrator' group
RUN sed -i 's/Defaults !requiretty/Defaults requiretty/' /etc/sudoers && \
echo 'admin ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers && \
echo 'ubuntu ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
#RUN echo "%administrator ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
# Generate SSH host keys
RUN ssh-keygen -A
# Secure SSH configuration
RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin no/' /etc/ssh/sshd_config && \
sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config && \
sed -i 's/#ChallengeResponseAuthentication yes/ChallengeResponseAuthentication no/' /etc/ssh/sshd_config && \
sed -i 's/#UsePAM yes/UsePAM no/' /etc/ssh/sshd_config && \
sed -i 's/#Port 22/Port 2222/' /etc/ssh/sshd_config && \
echo "AllowUsers admin" >> /etc/ssh/sshd_config
# Copy SSH keys to /app/ssh and set permissions
RUN cp -r /etc/ssh/* /app/ssh && \
chmod -R 777 /etc/ssh/* /app/ssh/* && \
touch /app/ssh/ssh_known_hosts && \
chmod 777 /app/ssh/ssh_known_hosts
# List contents of /etc/ssh and /app/ssh
RUN ls -l /etc/ssh/ && \
ls -l /app/ssh/
# Create administrator group and admin user with full permissions
#RUN groupadd -f administrator && \
# id -u admin >/dev/null 2>&1 || useradd -m -s /bin/bash -G administrator,sudo admin && \
# echo 'admin:password' | chpasswd && \
# echo "%administrator ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
# Install WebSSH dependencies
RUN python3 -m venv /app/WebSSHEnv && \
/app/WebSSHEnv/bin/pip install --no-cache-dir --upgrade pip && \
/app/WebSSHEnv/bin/pip install --no-cache-dir webssh && \
/app/WebSSHEnv/bin/pip list
# Change ownership of /home/admin directory
#RUN chown -R admin:admin /home/admin
# Set working directory
#WORKDIR /app
# Expose necessary ports
EXPOSE 7860 2222
# Switch to 'admin' user and set working directory
#WORKDIR /home/admin
# Change ownership of /home/admin directory
#RUN chown -R admin:admin /home/admin
#RUN cat /etc/passwd && \
# cat /etc/group && \
# cat /etc/sudoers && \
# cat /etc/shadow
RUN chmod -R 777 /app /home
#USER admin
# Default command to keep the container running
CMD ["/app/start.sh"]
|