sshd_config - make 'Port' config key overridable using an env var #382
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As atmoz/sftp is a docker image by design, one can already simply change the exposed port of the running server using the appropriate docker run options, to map the internal port 22 to any external port.
It works very well in the majority of cases, as I've been able to experiment it myself.
However, there are a few cases where it is either not wanted or not possible to use this port mapping features.
For example, if you use atmoz/sftp in a CircleCI build, you won't be able to change the port mapping ( https://discuss.circleci.com/t/change-db-containers-ports/30234/6 ), even while the port 22 is reserved by CircleCI, and not usable to containers launched in the tests.
I've read about the custom scripts located in
/etc/sftp.d
( https://github.com/atmoz/sftp#execute-custom-scripts-or-applications ) that might already allow one to override everything we want, but that might sounds a bit overengineered to provide a custom executable bash scripts to update a simple config key (this is opinionated, I'm ready to hear any different opinions on this)Given the reasons listed above, I feel that it is reasonable to allow a user to override the SSHD port using a simple environment variable.
This Pull Request suggests an implementation of this.