Skip to content

Commit

Permalink
feat(sshd_config): let the sshd port to be changed using a env var
Browse files Browse the repository at this point in the history
  • Loading branch information
FXHibon committed Jul 17, 2023
1 parent eacf693 commit da094d5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
FROM debian:bullseye
MAINTAINER Adrian Dvergsdal [atmoz.net]

ENV SSHD_PORT 22

# Steps done in one RUN layer:
# - Install packages
# - OpenSSH needs /var/run/sshd to run
Expand All @@ -15,6 +17,4 @@ COPY files/sshd_config /etc/ssh/sshd_config
COPY files/create-sftp-user /usr/local/bin/
COPY files/entrypoint /

EXPOSE 22

ENTRYPOINT ["/entrypoint"]
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Easy to use SFTP ([SSH File Transfer Protocol](https://en.wikipedia.org/wiki/SSH
own home directory, so make sure there are at least one subdirectory if you
want them to upload files.
- For consistent server fingerprint, mount your own host keys (i.e. `/etc/ssh/ssh_host_*`)
- Override port
- The container will listen on the port 22 (default for sshd), but if for any reasons you want an another port to be used instead of the default, you can change it with the env var SSHD_PORT

# Examples

Expand Down
3 changes: 3 additions & 0 deletions files/entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ if [ -d /etc/sftp.d ]; then
unset f
fi


sed -i "s/SSHD_PORT/$SSHD_PORT/" /etc/ssh/sshd_config

if $startSshd; then
log "Executing sshd"
exec /usr/sbin/sshd -D -e
Expand Down
2 changes: 2 additions & 0 deletions files/sshd_config
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ ChrootDirectory %h

# Enable this for more logs
#LogLevel VERBOSE

Port SSHD_PORT

0 comments on commit da094d5

Please sign in to comment.