Skip to content

Commit 47380dd

Browse files
committed
add create sysadmin user and add to sudoers
1 parent 7386b3e commit 47380dd

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

bastion/Dockerfile

+27-3
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,40 @@ RUN apt-get update
1717
# Install git
1818
RUN apt-get install -y \
1919
git \
20+
sed \
2021
ca-certificates \
22+
openssh-client \
23+
openssh-server \
2124
&& update-ca-certificates
2225

26+
# Clean up packages: Saves space by removing unnecessary package files and lists
27+
RUN apt-get clean
28+
RUN rm -rf /var/lib/apt/lists/*
29+
30+
# Create sysadmin user and add to sudoers
31+
RUN useradd -m -s /bin/bash sysadmin && echo "sysadmin:sysadmin" | chpasswd && \
32+
usermod -aG sudo sysadmin
33+
34+
# Ensure SSH directory exists with correct permissions
35+
RUN mkdir -p /home/sysadmin/.ssh && \
36+
chown sysadmin:sysadmin /home/sysadmin/.ssh && \
37+
chmod 700 /home/sysadmin/.ssh
38+
39+
# Create privilege separation directory for SSH
40+
RUN mkdir -p /run/sshd
41+
2342
# Follows the instructions here:
2443
# https://ovh.github.io/the-bastion/installation/basic.html
2544
RUN git clone https://github.com/ovh/the-bastion /opt/bastion
2645
RUN git -C /opt/bastion checkout $(git -C /opt/bastion tag | tail -1)
27-
2846
RUN /opt/bastion/bin/admin/packages-check.sh -i
29-
3047
RUN /opt/bastion/bin/admin/install --new-install
3148

32-
RUN /opt/bastion/bin/admin/setup-first-admin-account.sh sysadmin auto
49+
# Allow SSH jumping
50+
RUN sed -i 's/AllowTcpForwarding no/AllowTcpForwarding yes/' /etc/ssh/sshd_config
51+
52+
# Expose SSH port
53+
EXPOSE 22
54+
55+
# Start SSH service
56+
ENTRYPOINT ["/opt/bastion/docker/entrypoint.sh"]

docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ services:
101101
- ./sysadmin-ssh-keys/rsa_sysadmin:/home/sysadmin/.ssh/id_rsa:ro
102102
- ./sysadmin-ssh-keys/rsa_sysadmin.pub:/home/sysadmin/.ssh/id_rsa.pub:ro
103103
- ./sysadmin-ssh-keys/rsa_sysadmin.pub:/home/sysadmin/.ssh/authorized_keys:ro
104-
104+
105105
volumes:
106106
db-data:
107107
name: db-data

0 commit comments

Comments
 (0)