fix(docker): mount --ssh keys outside /root for --host shells - #20
Merged
Conversation
`pix shell --host` drops privileges to a non-root user matching the host
UID, but `--ssh <id>=<key>` mounted the key under /root/.ssh (mode 0700),
which that user cannot traverse. git then failed with "Identity file not
accessible: Permission denied", and because GIT_SSH_COMMAND pins
IdentitiesOnly=yes it could not fall back to the forwarded agent either
("Permission denied (publickey)").
Mount user-provided keys under /pix/ssh instead. Docker creates the
intermediate mount dirs as world-traversable 0755, and the key keeps its
host ownership (matching the host UID under --host), so the dropped user
can read it while root still can too. IdentitiesOnly=yes is preserved.
Author
|
--ssh spec |
Agent forwarded | Key mounted | GIT_SSH_COMMAND |
Affected by this PR |
|---|---|---|---|---|
default |
yes | no | no | no (unchanged) |
default=<key> |
yes | /pix/ssh/<key> |
-i /pix/ssh/<key> -o IdentitiesOnly=yes |
yes (mount path only) |
id=<key> |
no | /pix/ssh/<key> |
same | yes (mount path only) |
/path/to/key |
no | /pix/ssh/<key> |
same | yes (mount path only) |
meox
force-pushed
the
fix/ssh-key-mount-host
branch
from
July 2, 2026 11:50
c0887d4 to
cad0c5d
Compare
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.
Problem
pix shell --hostdrops privileges to a non-root user whose UID matches thehost user (so bind-mounted files keep correct ownership). However,
--ssh <id>=<key>mounts the key under/root/.ssh/<name>and pinsGIT_SSH_COMMAND=ssh -i /root/.ssh/<name> -o IdentitiesOnly=yes ..../rootis mode0700, so the dropped user cannot even traverse into it:IdentitiesOnly=yesadditionally prevents SSH from falling back to theforwarded agent, so
mix deps.get(and any git-over-SSH) fails insidepix shell --hosteven though both the key and the agent are available.Fix
Mount user-provided SSH keys under
/pix/ssh/<name>instead of/root/.ssh/<name>. Docker creates the intermediate mount directories asworld-traversable
0755, and the mounted key keeps its host ownership(matching the host UID under
--host), so:--host) shell.IdentitiesOnly=yesis intentionally preserved, so pix keeps using exactly thespecified key (avoiding "too many authentication failures" when the agent holds
many keys). Only the mount location changes.
Testing
mix format --check-formatted,mix compile --warnings-as-errors, andmix credo --strictall pass.host UID,
IdentitiesOnly=yes, no agent fallback):/root/.ssh→Permission denied(before)/pix/ssh→ readable, andssh -T git@github.comauthenticatessuccessfully (after)