From 5ff0f33e043bbd74b87490110ca5cd0303b34b08 Mon Sep 17 00:00:00 2001 From: Sergio Borghese Date: Wed, 18 Mar 2026 15:35:46 +0100 Subject: [PATCH 1/9] using -slim version of debian image --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index bd6bd38c..0d4936e7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM debian:bookworm +FROM debian:bookworm-slim MAINTAINER Adrian Dvergsdal [atmoz.net] # Steps done in one RUN layer: From 364f62369d20c8660449054a37cc98808e8a9c81 Mon Sep 17 00:00:00 2001 From: Sergio Borghese Date: Wed, 18 Mar 2026 21:38:15 +0100 Subject: [PATCH 2/9] sample configuration for docker compose --- logos.sftp.server.env | 18 ++++++++++++++++++ logos.sftp.server.yml | 11 +++++++++++ 2 files changed, 29 insertions(+) create mode 100644 logos.sftp.server.env create mode 100644 logos.sftp.server.yml diff --git a/logos.sftp.server.env b/logos.sftp.server.env new file mode 100644 index 00000000..7f7f3fb6 --- /dev/null +++ b/logos.sftp.server.env @@ -0,0 +1,18 @@ + +SFTP_IMAGE="logos/sftp-server:0.2" +SFTP_HOSTNAME="logos.sftp.srv.01" +SFTP_HOST_PORT=3322 + +SFTP_USERNAME="foo" +# sample cfg password is: pass +# to generate the encrypted pwd run: python3 -c "import crypt; print(crypt.crypt('YOUR_PASSWORD'))" +SFTP_ENCRYPTED_PWD=$6$4W/2yGfDbmbuHL8i$jhNepgWX1l/ZNzQNkkCIEx86dzCJjrp6BEHPlq6vvOX1QBySXaimK1WYbmcGxIs3bGSXzbOPBgKdpmD82qOln0 +SFTP_HOST_UID=590201106 + +SFTP_HOST_UPLOAD_FOLDER="/home/netresults.wintranet/borghese/tmp/logos-upload-folder" +SFTP_UPLOAD_FOLDER="/home/foo/upload" + +# Format is: +# username:encrypted_passwd:e:[UID]:[GID]: +ENV_SFTP_USERS=${SFTP_USERNAME}:${SFTP_ENCRYPTED_PWD}:e:${SFTP_HOST_UID}:: + diff --git a/logos.sftp.server.yml b/logos.sftp.server.yml new file mode 100644 index 00000000..c5452dc1 --- /dev/null +++ b/logos.sftp.server.yml @@ -0,0 +1,11 @@ +logos.sftp.srv: + image: ${SFTP_IMAGE} + restart: unless-stopped + hostname: ${SFTP_HOSTNAME} + environment: + SFTP_USERS: ${ENV_SFTP_USERS} + volumes: + - ${SFTP_HOST_UPLOAD_FOLDER}:${SFTP_UPLOAD_FOLDER} + ports: + - "${SFTP_HOST_PORT}:22" + From d21f7043aebbc50cf840885d8bcc12ed7d05b4fe Mon Sep 17 00:00:00 2001 From: Sergio Borghese Date: Wed, 18 Mar 2026 21:59:33 +0100 Subject: [PATCH 3/9] add util to generate hashed pwd --- genpwd.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 genpwd.py diff --git a/genpwd.py b/genpwd.py new file mode 100644 index 00000000..5b85b32f --- /dev/null +++ b/genpwd.py @@ -0,0 +1,15 @@ +import bcrypt +import sys + + +def main(): + print(f"hashing password: {sys.argv[1]}") + password = sys.argv[1] + salt = bcrypt.gensalt(10) + hashed = bcrypt.hashpw(password.encode(), salt) + print(f"hashed password: {hashed}") + + +if __name__ == "__main__": + raise SystemExit(main()) + From d4c0ee447f9b7794d18cea1fdf51a92f9a8ff2f4 Mon Sep 17 00:00:00 2001 From: Sergio Borghese Date: Wed, 18 Mar 2026 22:00:01 +0100 Subject: [PATCH 4/9] use hased pwd generated with bcrypt algo --- logos.sftp.server.env | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/logos.sftp.server.env b/logos.sftp.server.env index 7f7f3fb6..121e666f 100644 --- a/logos.sftp.server.env +++ b/logos.sftp.server.env @@ -5,8 +5,8 @@ SFTP_HOST_PORT=3322 SFTP_USERNAME="foo" # sample cfg password is: pass -# to generate the encrypted pwd run: python3 -c "import crypt; print(crypt.crypt('YOUR_PASSWORD'))" -SFTP_ENCRYPTED_PWD=$6$4W/2yGfDbmbuHL8i$jhNepgWX1l/ZNzQNkkCIEx86dzCJjrp6BEHPlq6vvOX1QBySXaimK1WYbmcGxIs3bGSXzbOPBgKdpmD82qOln0 +# to generate the encrypted pwd run: python3 genpwd.py" +SFTP_ENCRYPTED_PWD=$2b$10$lCXQfDMMc4nibdLnDk1ycundyYX/eFDO8Q0Nvj81y78ssk4TqZtHO SFTP_HOST_UID=590201106 SFTP_HOST_UPLOAD_FOLDER="/home/netresults.wintranet/borghese/tmp/logos-upload-folder" From 42d17ba3095903c99edf4087469f61b01e2733a2 Mon Sep 17 00:00:00 2001 From: Sergio Borghese Date: Wed, 18 Mar 2026 22:56:27 +0100 Subject: [PATCH 5/9] fix typos --- Dockerfile | 2 ++ healthcheck.sh | 12 ++++++++++++ 2 files changed, 14 insertions(+) create mode 100755 healthcheck.sh diff --git a/Dockerfile b/Dockerfile index 0d4936e7..7846201c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,12 +8,14 @@ MAINTAINER Adrian Dvergsdal [atmoz.net] RUN apt-get update && \ apt-get upgrade -y && \ DEBIAN_FRONTEND="noninteractive" apt-get -y install --no-install-recommends openssh-server && \ + apt-get -y install --no-install-recommends netcat-openbsd && \ rm -rf /var/lib/apt/lists/* && \ mkdir -p /var/run/sshd && \ rm -f /etc/ssh/ssh_host_*key* COPY files/sshd_config /etc/ssh/sshd_config COPY files/create-sftp-user /usr/local/bin/ +COPY files/healthcheck.sh /usr/local/bin/ COPY files/entrypoint / EXPOSE 22 diff --git a/healthcheck.sh b/healthcheck.sh new file mode 100755 index 00000000..2de5120a --- /dev/null +++ b/healthcheck.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# 1. Check if the sshd process is actually running +pgrep sshd > /dev/null || exit 1 + +# 2. Try to open a TCP connection to the SSH port locally +# -z: scan for listening daemons without sending data +# -w 2: timeout after 2 seconds +nc -z -w 2 localhost 22 || exit 1 + +exit 0 + From 11a8b3932f99c8db99b107470e5727d7dfe8752b Mon Sep 17 00:00:00 2001 From: Sergio Borghese Date: Wed, 18 Mar 2026 22:57:07 +0100 Subject: [PATCH 6/9] add healthcheck script --- files/healthcheck.sh | 12 ++++++++++++ logos.sftp.server.env | 9 ++++++++- logos.sftp.server.yml | 28 ++++++++++++++++++---------- 3 files changed, 38 insertions(+), 11 deletions(-) create mode 100755 files/healthcheck.sh diff --git a/files/healthcheck.sh b/files/healthcheck.sh new file mode 100755 index 00000000..2de5120a --- /dev/null +++ b/files/healthcheck.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# 1. Check if the sshd process is actually running +pgrep sshd > /dev/null || exit 1 + +# 2. Try to open a TCP connection to the SSH port locally +# -z: scan for listening daemons without sending data +# -w 2: timeout after 2 seconds +nc -z -w 2 localhost 22 || exit 1 + +exit 0 + diff --git a/logos.sftp.server.env b/logos.sftp.server.env index 121e666f..50e73e8e 100644 --- a/logos.sftp.server.env +++ b/logos.sftp.server.env @@ -1,5 +1,5 @@ -SFTP_IMAGE="logos/sftp-server:0.2" +SFTP_IMAGE="logos/sftp-server:0.3" SFTP_HOSTNAME="logos.sftp.srv.01" SFTP_HOST_PORT=3322 @@ -16,3 +16,10 @@ SFTP_UPLOAD_FOLDER="/home/foo/upload" # username:encrypted_passwd:e:[UID]:[GID]: ENV_SFTP_USERS=${SFTP_USERNAME}:${SFTP_ENCRYPTED_PWD}:e:${SFTP_HOST_UID}:: +# container healthcheck session +HEALTCHECK_CMD=["CMD", "/usr/local/bin/healthcheck.sh"] +HEALTHCHECK_INTERVAL_SEC=60s +HEALTHCHECK_TIMEOUT_SEC=5s +HEALTHCHECK_RETRIES=3 +HEALTCHECK_START_PERIOD_SEC=30s + diff --git a/logos.sftp.server.yml b/logos.sftp.server.yml index c5452dc1..35917630 100644 --- a/logos.sftp.server.yml +++ b/logos.sftp.server.yml @@ -1,11 +1,19 @@ -logos.sftp.srv: - image: ${SFTP_IMAGE} - restart: unless-stopped - hostname: ${SFTP_HOSTNAME} - environment: - SFTP_USERS: ${ENV_SFTP_USERS} - volumes: - - ${SFTP_HOST_UPLOAD_FOLDER}:${SFTP_UPLOAD_FOLDER} - ports: - - "${SFTP_HOST_PORT}:22" + +services: + logos.sftp.srv: + image: ${SFTP_IMAGE} + restart: unless-stopped + hostname: ${SFTP_HOSTNAME} + environment: + SFTP_USERS: ${ENV_SFTP_USERS} + volumes: + - ${SFTP_HOST_UPLOAD_FOLDER}:${SFTP_UPLOAD_FOLDER} + ports: + - "${SFTP_HOST_PORT}:22" + healthcheck: + test: ${HEALTCHECK_CMD} + interval: ${HEALTHCHECK_INTERVAL_SEC} + timeout: ${HEALTHCHECK_TIMEOUT_SEC} + retries: ${HEALTHCHECK_RETRIES} + start_period: ${HEALTCHECK_START_PERIOD_SEC} From 7bf6095e48a2f89c046770d6d3fe9fb1b0173b94 Mon Sep 17 00:00:00 2001 From: Sergio Borghese Date: Wed, 18 Mar 2026 22:57:32 +0100 Subject: [PATCH 7/9] rm old file --- healthcheck.sh | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100755 healthcheck.sh diff --git a/healthcheck.sh b/healthcheck.sh deleted file mode 100755 index 2de5120a..00000000 --- a/healthcheck.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -# 1. Check if the sshd process is actually running -pgrep sshd > /dev/null || exit 1 - -# 2. Try to open a TCP connection to the SSH port locally -# -z: scan for listening daemons without sending data -# -w 2: timeout after 2 seconds -nc -z -w 2 localhost 22 || exit 1 - -exit 0 - From 9618e784690a6dbefad7700ccd64e07309353572 Mon Sep 17 00:00:00 2001 From: Sergio Borghese Date: Thu, 19 Mar 2026 12:30:51 +0100 Subject: [PATCH 8/9] Initial commit --- README.md | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 00000000..25cc4a96 --- /dev/null +++ b/README.md @@ -0,0 +1,93 @@ +# Logos SFTP Server + + + +## Getting started + +To make it easy for you to get started with GitLab, here's a list of recommended next steps. + +Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! + +## Add your files + +* [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files +* [Add files using the command line](https://docs.gitlab.com/topics/git/add_files/#add-files-to-a-git-repository) or push an existing Git repository with the following command: + +``` +cd existing_repo +git remote add origin https://gitlab.netresults.dev/netresults/kalliopelab/logos-sftp-server.git +git branch -M main +git push -uf origin main +``` + +## Integrate with your tools + +* [Set up project integrations](https://gitlab.netresults.dev:10443/netresults/kalliopelab/logos-sftp-server/-/settings/integrations) + +## Collaborate with your team + +* [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/) +* [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html) +* [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically) +* [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/) +* [Set auto-merge](https://docs.gitlab.com/user/project/merge_requests/auto_merge/) + +## Test and Deploy + +Use the built-in continuous integration in GitLab. + +* [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/) +* [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/) +* [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html) +* [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/) +* [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html) + +*** + +# Editing this README + +When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template. + +## Suggestions for a good README + +Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information. + +## Name +Choose a self-explaining name for your project. + +## Description +Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors. + +## Badges +On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge. + +## Visuals +Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method. + +## Installation +Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection. + +## Usage +Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README. + +## Support +Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc. + +## Roadmap +If you have ideas for releases in the future, it is a good idea to list them in the README. + +## Contributing +State if you are open to contributions and what your requirements are for accepting them. + +For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self. + +You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser. + +## Authors and acknowledgment +Show your appreciation to those who have contributed to the project. + +## License +For open source projects, say how it is licensed. + +## Project status +If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers. From 862019060ae18c4af150016daf1aabc0b96aefe0 Mon Sep 17 00:00:00 2001 From: Sergio Borghese Date: Thu, 19 Mar 2026 13:51:26 +0100 Subject: [PATCH 9/9] fix healthcheck --- files/healthcheck.sh | 2 +- logos.sftp.server.env | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/files/healthcheck.sh b/files/healthcheck.sh index 2de5120a..d42822e2 100755 --- a/files/healthcheck.sh +++ b/files/healthcheck.sh @@ -6,7 +6,7 @@ pgrep sshd > /dev/null || exit 1 # 2. Try to open a TCP connection to the SSH port locally # -z: scan for listening daemons without sending data # -w 2: timeout after 2 seconds -nc -z -w 2 localhost 22 || exit 1 +nc -z -w 2 127.0.0.1 22 || exit 1 exit 0 diff --git a/logos.sftp.server.env b/logos.sftp.server.env index 50e73e8e..e9b85889 100644 --- a/logos.sftp.server.env +++ b/logos.sftp.server.env @@ -17,7 +17,7 @@ SFTP_UPLOAD_FOLDER="/home/foo/upload" ENV_SFTP_USERS=${SFTP_USERNAME}:${SFTP_ENCRYPTED_PWD}:e:${SFTP_HOST_UID}:: # container healthcheck session -HEALTCHECK_CMD=["CMD", "/usr/local/bin/healthcheck.sh"] +HEALTCHECK_CMD="/bin/bash /usr/local/bin/healthcheck.sh" HEALTHCHECK_INTERVAL_SEC=60s HEALTHCHECK_TIMEOUT_SEC=5s HEALTHCHECK_RETRIES=3