Skip to content

Commit 4d8ea13

Browse files
persistent host key support
1 parent 895b2e9 commit 4d8ea13

4 files changed

Lines changed: 30 additions & 1 deletion

File tree

.github/workflows/build.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ on:
44
schedule:
55
- cron: "0 0 1 * *" # every month
66
push:
7+
branches:
8+
- master
9+
- feature/persistent-host-key-support
710
paths-ignore:
811
- "*.md"
912
- "*.txt"
1013
- "*.png"
11-
pull_request:
1214

1315
env:
1416
IMAGE_NAME: ghcr.io/techonomydev/atmoz-sftp

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ RUN apt-get update && \
1313
COPY files/sshd_config /etc/ssh/sshd_config
1414
COPY files/create-sftp-user /usr/local/bin/
1515
COPY files/entrypoint /
16+
COPY files/startup_scripts/load_env_host_key.bash /etc/sftp.d/load_env_host_key.bash
17+
18+
RUN chmod +x /etc/sftp.d/*
1619

1720
EXPOSE 22
1821

Dockerfile-port-2222

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ RUN apt-get update && \
1313
COPY files/sshd_config_2222 /etc/ssh/sshd_config
1414
COPY files/create-sftp-user /usr/local/bin/
1515
COPY files/entrypoint /
16+
COPY files/startup_scripts/load_env_host_key.bash /etc/sftp.d/load_env_host_key.bash
17+
18+
RUN chmod +x /etc/sftp.d/*
1619

1720
EXPOSE 2222
1821

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
if [[ -n "$SSH_HOST_ED25519_KEY_B64" ]]; then
4+
echo "Decoding and setting up ED25519 host key..."
5+
echo "$SSH_HOST_ED25519_KEY_B64" | base64 -d > /etc/ssh/ssh_host_ed25519_key
6+
ssh-keygen -y -f /etc/ssh/ssh_host_ed25519_key > /etc/ssh/ssh_host_ed25519_key.pub
7+
chmod 600 /etc/ssh/ssh_host_ed25519_key
8+
echo "ED25519 host key setup complete."
9+
else
10+
echo "No ED25519 host key provided."
11+
fi
12+
13+
if [[ -n "$SSH_HOST_RSA_KEY_B64" ]]; then
14+
echo "Decoding and setting up RSA host key..."
15+
echo "$SSH_HOST_RSA_KEY_B64" | base64 -d > /etc/ssh/ssh_host_rsa_key
16+
ssh-keygen -y -f /etc/ssh/ssh_host_rsa_key > /etc/ssh/ssh_host_rsa_key.pub
17+
chmod 600 /etc/ssh/ssh_host_rsa_key
18+
echo "RSA host key setup complete."
19+
else
20+
echo "No RSA host key provided."
21+
fi

0 commit comments

Comments
 (0)