Skip to content

Commit 61ba0ce

Browse files
lloydchangCoordHealthhalifrieritushcmdPardaz Banu Mohammad
committed
fix: security
* Remove hardcoded root password * Prevent root SSH access * Use privilege escalation to root Co-authored-by: Haley Lifrieri <haleylifrieri@college.harvard.edu> Co-authored-by: Haley Lifrieri <halifrieri@gmail.com> Co-authored-by: Muturi David <muturidavid854@gmail.com> Co-authored-by: Pardaz Banu Mohammad <pardaz.banu786@gmail.com> Co-authored-by: Pardaz Banu Mohammad <pardazbanu1999@gmail.com> Co-authored-by: Toluwalope Olateru-Olagbeg <wole2003@gmail.com>
1 parent be5d2bd commit 61ba0ce

File tree

3 files changed

+215
-161
lines changed

3 files changed

+215
-161
lines changed

Dockerfile

Lines changed: 0 additions & 37 deletions
This file was deleted.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# codespaces_create_and_start_containers.Dockerfile
2+
3+
FROM ubuntu:latest
4+
5+
ENV DEBIAN_FRONTEND=noninteractive
6+
7+
# Use the TIMEZONE variable to configure the timezone
8+
ENV TIMEZONE=Etc/UTC
9+
RUN ln -fs /usr/share/zoneinfo/$TIMEZONE /etc/localtime && echo $TIMEZONE > /etc/timezone
10+
11+
# Update package list and install dependencies in one line
12+
RUN apt-get update && apt-get install -y \
13+
software-properties-common \
14+
openssh-server \
15+
sudo \
16+
python3 \
17+
python3-venv \
18+
python3-setuptools \
19+
python3-wheel \
20+
python3-apt \
21+
passwd \
22+
tzdata \
23+
iproute2 \
24+
wget \
25+
cron \
26+
--no-install-recommends && \
27+
add-apt-repository ppa:deadsnakes/ppa -y && \
28+
apt-get update && apt-get install -y \
29+
python3.11 \
30+
python3.11-venv \
31+
python3.11-distutils \
32+
python3.11-dev && \
33+
dpkg-reconfigure --frontend noninteractive tzdata && \
34+
apt-get clean && \
35+
rm -rf /var/lib/apt/lists/*
36+
37+
# Install pip using get-pip.py
38+
RUN wget https://bootstrap.pypa.io/get-pip.py && python3.11 get-pip.py && rm get-pip.py
39+
40+
# Install required Python packages
41+
RUN python3.11 -m pip install --no-cache-dir passlib cffi cryptography
42+
43+
# Ensure python3-apt is properly installed and linked
44+
RUN ln -s /usr/lib/python3/dist-packages/apt_pkg.cpython-310-x86_64-linux-gnu.so /usr/lib/python3/dist-packages/apt_pkg.so || true
45+
46+
# Prepare SSH server
47+
RUN mkdir /var/run/sshd
48+
49+
# Create ansible user
50+
RUN useradd -m -s /bin/bash ansible
51+
52+
# Set up SSH for ansible
53+
RUN mkdir -p /home/ansible/.ssh && \
54+
chmod 700 /home/ansible/.ssh && \
55+
chown ansible:ansible /home/ansible/.ssh
56+
57+
# Configure sudo access for ansible
58+
RUN echo "ansible ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/ansible
59+
60+
# Disable root SSH login
61+
RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin no/' /etc/ssh/sshd_config
62+
63+
# Expose SSH port
64+
EXPOSE 22
65+
66+
# Start SSH server
67+
CMD ["/usr/sbin/sshd", "-D"]

0 commit comments

Comments
 (0)