Problem:
I'm trying to run a git clone myuser@server:repo.git from within a docker container. Inside the container (due to policy) I am the same user as on the docker host system (non-root) and have my home mounted.
Sadly when cloning from or trying to ssh into server i get an error message like this:
No user exists for uid 1337
MVCE:
To reproduce the problem you can run the following docker container:
docker run --rm -it -v /home/$USER:/home/$USER -e HOME=/home/$USER -w /home/$USER -u $UID:100 --cap-drop=ALL kiesel/debian-ssh-client
and inside the container either of the following commands:
git clone myuser@server:repo.git
ssh -vT myuser@server
Workaround:
Adding a faked /etc/passwd with a line for my uid seems to fix the problem (e.g., getent passwd $USER > /tmp/mypasswd, then add a -v /tmp/mypasswd:/etc/passwd:ro to the docker run cmd).
Sadly this requires shadowing/modifying the container's /etc/passwd, which i can imagine will lead to trouble at some point.
Questions:
- Why is ssh (client) looking at the local (container's)
/etc/passwd? - Is there a simple way to deactivate that (with user permissions)?