mirror of
https://github.com/atmoz/sftp.git
synced 2024-11-17 12:51:33 -05:00
Generate unique ssh keys for each container (issue #32)
This commit is contained in:
parent
2d7f37cd20
commit
a132b109df
2 changed files with 9 additions and 2 deletions
|
@ -5,8 +5,11 @@ RUN apt-get update && \
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get -y install openssh-server && \
|
DEBIAN_FRONTEND=noninteractive apt-get -y install openssh-server && \
|
||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# sshd needs this directory to run
|
# Step 1: sshd needs /var/run/sshd/ to run
|
||||||
RUN mkdir -p /var/run/sshd
|
# Step 2: Remove keys, they will be generated later by entrypoint
|
||||||
|
# (unique keys for each container)
|
||||||
|
RUN mkdir -p /var/run/sshd && \
|
||||||
|
rm /etc/ssh/ssh_host_*key*
|
||||||
|
|
||||||
COPY sshd_config /etc/ssh/sshd_config
|
COPY sshd_config /etc/ssh/sshd_config
|
||||||
COPY entrypoint /
|
COPY entrypoint /
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
userConfPath="/etc/sftp-users.conf"
|
userConfPath="/etc/sftp-users.conf"
|
||||||
userConfFinalPath="/var/run/sftp-users.conf"
|
userConfFinalPath="/var/run/sftp-users.conf"
|
||||||
|
@ -115,6 +116,9 @@ if [ ! -f "$userConfFinalPath" ]; then
|
||||||
createUser "$user"
|
createUser "$user"
|
||||||
done < "$userConfFinalPath"
|
done < "$userConfFinalPath"
|
||||||
|
|
||||||
|
# Generate unique ssh keys for this container
|
||||||
|
dpkg-reconfigure openssh-server
|
||||||
|
|
||||||
# Source custom scripts, if any
|
# Source custom scripts, if any
|
||||||
if [ -d /etc/sftp.d ]; then
|
if [ -d /etc/sftp.d ]; then
|
||||||
for f in /etc/sftp.d/*; do
|
for f in /etc/sftp.d/*; do
|
||||||
|
|
Loading…
Reference in a new issue