Spaces:
Paused
Paused
File size: 5,536 Bytes
15d9364 ca1110e d89b239 68f28c1 8b901d1 68f28c1 15d9364 2c76eb6 3e0c980 3ea2a08 2c76eb6 740e512 5ff8ab8 740e512 b2741c4 3ea2a08 2c76eb6 15d9364 d89b239 15d9364 cb46931 2f12044 d89b239 cf617b7 0729033 cf617b7 0729033 0b008e1 c7d3881 4586002 c7d3881 4586002 d89b239 2c76eb6 3d12fd6 8b901d1 910104c 6eaf352 009db59 e69d427 3d12fd6 9961e62 deba3e4 4e6d66e 568224a 8b901d1 7d79f33 6940227 7d79f33 d28fe2d 6940227 0729033 5d99ff8 568224a 131d8db d44e8e5 613e0f8 d44e8e5 3d12fd6 d44e8e5 8b901d1 d44e8e5 8b901d1 6eaf352 3d12fd6 568224a 3d12fd6 d44e8e5 1f9114d d44e8e5 3d12fd6 0d33a90 3323af7 98930dc cf617b7 0d33a90 175a5fd 0d33a90 175a5fd 0d33a90 d44e8e5 105939e 024f413 0d33a90 7163fa2 cf617b7 |
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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# 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 \
ufw\
sudo\
bash \
passwd\
sshpass\
python3\
keychain\
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 -u 1000 admin && \
echo "admin:password" | chpasswd &&\
usermod -aG sudo admin && \
echo "admin ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
#ENV HOME =/home/admin &&\
# PATH =/home/admin/.local/bin:$PATH
# usermod -aG sudo admin && \
# 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
# chmod -R 777 /home/admin/.ssh && \
#cp /app/ssh_config /home/admin/.ssh/config
#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 &&\
# sudo ufw allow 2222/tcp
#RUN sudo ufw disable
RUN cp /app/sshd_config /etc/ssh/sshd_config # && cat /etc/ssh/sshd_config
RUN chmod -R 755 /etc/ssh/* &&\
rm -f /etc/ssh/ssh_host_rsa_* && \
rm -f /etc/ssh/ssh_host_ecdsa_* && \
rm -f /etc/ssh/ssh_host_ed25519_* && \
rm -f /etc/ssh/ssh_known_* && \
touch /etc/ssh/ssh_known_hosts
RUN yes y | ssh-keygen -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -N "" && \
yes y | ssh-keygen -t ecdsa -b 256 -f /etc/ssh/ssh_host_ecdsa_key -N "" && \
yes y | ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N "" && \
ssh-keygen -Hf /etc/ssh/ssh_known_hosts && \
chmod -R 755 /etc/ssh/* && \
echo " Public Key $(cat /etc/ssh/ssh_host_rsa_key.pub)" && \
echo " Private Key $(cat /etc/ssh/ssh_host_rsa_key)"
#ssh-keyscan -p 2222 0.0.0.0 >> /etc/ssh/ssh_known_hosts
# Secure SSH Configuration
#RUN sed -i 's/#PermitRootLogin yes/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 *" >> /etc/ssh/sshd_config && \
# echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config && \
# echo "PubkeyAuthentication yes" >> /etc/ssh/sshd_config && \
# echo "AuthorizedKeysFile .ssh/authorized_keys" >> /etc/ssh/sshd_config && \
# Copy all the contents of /etc/ssh to /app/ssh
#RUN mkdir -p /app/ssh && cp -r /etc/ssh/* /app/ssh
# Set the permissions for the SSH keys
#RUN chmod 777 /etc/ssh/ssh_* && \
# touch /app/ssh/ssh_known_hosts && \
# chmod 777 /app/ssh/ssh_* && \
# chmod 777 /home
# List contents of /etc/ssh and /app/ssh
RUN ls -la /etc/ssh/ # && ls -l /app/ssh/
# Install WebSSH
RUN python3 -m venv /app/WebSSHEnv && \
/app/WebSSHEnv/bin/pip install --no-cache-dir --upgrade pip && \
/app/WebSSHEnv/bin/pip install --no-cache-dir -r /app/WebSSH/requirements.txt && \
/app/WebSSHEnv/bin/pip list
# Expose the new SSH port
EXPOSE 2222
EXPOSE 7860
RUN chmod -R 777 /app
USER admin
WORKDIR /home/admin
# Generate SSH keys
#RUN ssh-keygen -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -N "" -y && \
# ssh-keygen -t ecdsa -b 256 -f /etc/ssh/ssh_host_ecdsa_key -N "" -y && \
# ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N "" -y
# Copy the start.sh script
#RUN chmod 777 /app/venv/lib/python3.12/site-packages/
#RUN touch /app/venv/lib/python3.12/site-packages/known_hosts
#RUN chmod 777 /app/venv/lib/python3.12/site-packages/known_hosts
#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"]
ENTRYPOINT ["/app/start.sh"] |