fix: persist Docker environment variables into SSH login sessions - #127
Merged
Conversation
- Write container env vars to /etc/madz-env.sh at entrypoint startup so they are sourced into every SSH user session via profile.d - Update .profile to source /etc/profile.d/madz-env.sh - Replace hardcoded AcceptEnv list with AcceptEnv * for development
avoidwork
enabled auto-merge (squash)
June 7, 2026 14:57
avoidwork
disabled auto-merge
June 7, 2026 14:58
- Write container env vars to /etc/madz-env.sh at entrypoint startup so they are sourced into every SSH user session via profile.d - Update .profile to source /etc/profile.d/madz-env.sh - Add AcceptEnv * to sshd_config for development Key fix: use 'tr /proc/self/environ' instead of command substitution to avoid command-line argument length limits that silently truncated the env dump.
avoidwork
force-pushed
the
feat/fix-ssh-env-var-forwarding
branch
from
June 7, 2026 15:43
58de7f5 to
b46c9fc
Compare
avoidwork
enabled auto-merge (squash)
June 7, 2026 15:43
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Environment variables set by Docker (e.g. via
docker-compose.ymlenvironment:keys or--env) were not available in SSH login sessions, even though they worked fine inside the container fornpm start.Why
The previous entrypoint used
evalto export env vars only within the entrypoint process context. When a user connected via SSH, sshd spawned a new login shell that sourced.profile, but the Docker-injected variables were not persisted anywhere accessible to that session.How
Three changes:
docker-entrypoint.sh— reads env vars from/proc/self/environ, filters internal vars, and writes them asexport KEY=valuestatements to/etc/madz-env.sh. Creates a profile.d script so every login shell sources this file.Dockerfile—.profilenow sources/etc/profile.d/madz-env.shbefore runningnpm start, ensuring env vars are available both in SSH sessions and when npm starts.sshd_config— replaced the hardcodedAcceptEnv OPENAI_API_KEY,AcceptEnv OPENROUTER_API_KEY, etc. list withAcceptEnv *for development simplicity.Testing
Checklist
oxlintandoxfmtpass