Closed miniBill closed 3 years ago
Usernamespaces only allow to map a single uid (your own) to a different uid in the usernamespace. Hence all other uids will be mapped to nobody. We need usernamespaces in order to use mountnamespaces without root. This is a fundamental disadvantage and I don't see any other way around it except having nix-user-chroot
requiring root, which would defeat its purpose.
You might be able to build a similiar environment to nix-user-chroot with bubblewrap and mount a user owned ssh configuration to /etc/ssh/ssh_config.d/
but than you would also need to map your own uid to root to make openssh happy.
So using bubblewrap I could have a different ssh config that doesn't do the include I guess? I expect it could work.
Can I tell git/ssh to just ignore the config in /etc/ssh
?
ETA: bubblewarp is setuid though, so it kinda defeats the purpose of "install nix without being root" I guess :thinking:
bubblewrap also works without setuid. We use this in one fshUserenv implementation in nixpkgs. Bubblewrap would allow you to bind mount a different /etc/ssh/
. You would need to run bubblewrap so it bind mounts your nix store to /nix
.
A workaround for this issue is to explicitly specify a configfile on the command line:
ssh -F ~/.ssh/config ...
From the man page:
-F configfile
Specifies an alternative per-user configuration file. If a con‐
figuration file is given on the command line, the system-wide
configuration file (/etc/ssh/ssh_config) will be ignored. The
default for the per-user configuration file is ~/.ssh/config.
If set to “none”, no configuration files will be read.
How to reproduce
/etc/ssh/ssh_config
, have a line likeInclude /etc/ssh/ssh_config.d/*.conf
/etc/ssh/ssh_config.d
, owned byroot
nix-user-chroot ~/.nix ssh git@github.com -vvv
What happens
What should happen
ssh
works correctlyWhy does this happen
That file, from inside the chroot, appears as owned by
nobody
. Interestingly enough,/etc/ssh_config
is "owned" bynobody
too, but it doesn't trigger the errorHow to fix this
Uh. Maybe have ssh not read those??? It's not a great solution, tbh.
I cannot delete that file or integrate it inside the main
ssh_config
unfortunately.Another option would be to allow additional bind mounts as options from the CLI?