Skip to content

Commit 09382c6

Browse files
committed
fixed dockerfile security
1 parent 69a06db commit 09382c6

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

docker/base/amd64/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ RUN \
2323

2424
RUN \
2525
/usr/bin/ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
26-
echo 'root:Hello1234' | chpasswd && \
2726
groupadd -r admin && useradd -g admin admin && \
2827
yum install -y man && \
2928
yum install -y dstat && \
@@ -39,6 +38,8 @@ RUN \
3938
ssh-keygen -q -N "" -t rsa -f /etc/ssh/ssh_host_rsa_key && \
4039
sed -ri 's/session required pam_loginuid.so/#session required pam_loginuid.so/g' /etc/pam.d/sshd && \
4140
sed -i -e 's/^#Port 22$/Port 2222/' /etc/ssh/sshd_config && \
41+
sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin prohibit-password/' /etc/ssh/sshd_config && \
42+
sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication no/' /etc/ssh/sshd_config && \
4243
mkdir -p /root/.ssh && chown root.root /root && chmod 700 /root/.ssh && \
4344
yum install -y cronie && \
4445
sed -i '/session required pam_loginuid.so/d' /etc/pam.d/crond && \

docker/base/arm64/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ RUN \
2323

2424
RUN \
2525
/usr/bin/ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
26-
echo 'root:Hello1234' | chpasswd && \
2726
groupadd -r admin && useradd -g admin admin && \
2827
yum install -y man && \
2928
yum install -y dstat && \
@@ -39,6 +38,8 @@ RUN \
3938
ssh-keygen -q -N "" -t rsa -f /etc/ssh/ssh_host_rsa_key && \
4039
sed -ri 's/session required pam_loginuid.so/#session required pam_loginuid.so/g' /etc/pam.d/sshd && \
4140
sed -i -e 's/^#Port 22$/Port 2222/' /etc/ssh/sshd_config && \
41+
sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin prohibit-password/' /etc/ssh/sshd_config && \
42+
sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication no/' /etc/ssh/sshd_config && \
4243
mkdir -p /root/.ssh && chown root.root /root && chmod 700 /root/.ssh && \
4344
yum install -y cronie && \
4445
sed -i '/session required pam_loginuid.so/d' /etc/pam.d/crond && \

0 commit comments

Comments
 (0)