-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] add new adduser-ssh
command to simplify user creation
#488
Conversation
63cd5b1
to
48d2de5
Compare
This is a neat idea, and I'm not suggesting blocking it. But one observation is that this is actually not bootable container-specific and it would make a lot of sense to have it built into existing tools instead. E.g. I'm aware of the practicalities of trying to get this into OpenSSH of course. (Though it might be easier than we think?) But the more general idea is that in this "toolbox" approach, there might be other opportunities of this kind to enhance existing tools rather than owning those pieces and having users learn more tools. But again, yes this is a QOL improvement today. Just something to keep in mind. |
I see your point, although currently
There's a lot of overlap I think...the biggest difference conceptually is the question of whether we ship (one or more) tools that accepts (one or more) declarative config files as input, vs exposing a CLI. These aren't mutually exclusive of course, and in some cases it may make sense to have individual CLI tools - the ssh case could very much be one of those. One thing I think is important to consider here is that for some of this configuration, it's desirable to support both machine-specific config (i.e. injected into disk images) and generic configuration.
All of those for example are expressible in kickstart/blueprint today, and I think it'd be nice to be able to pass one (or both) of those formats both at container build time (hence making it generic) as well as at disk image generation (bib), or with anaconda. WDYT? |
In order to add user with ssh keys to an bootc image a fairly complicated commandline is used today [0]: ```Containerfile FROM quay.io/centos-bootc/centos-bootc:stream9 COPY wheel-nopasswd /etc/sudoers.d ARG sshpubkey RUN if test -z "$sshpubkey"; then echo "must provide sshpubkey"; exit 1; fi; \ useradd -G wheel exampleuser && \ mkdir -m 0700 -p /home/exampleuser/.ssh && \ echo $sshpubkey > /home/exampleuser/.ssh/authorized_keys && \ chmod 0600 /home/exampleuser/.ssh/authorized_keys && \ chown -R exampleuser: /home/exampleuser ``` With this commit this can be simplified to something like: ```Containerfile FROM quay.io/bootc/os-toolbox AS toolbox_stage FROM quay.io/centos-bootc/centos-bootc:stream9 RUN --mount=type=bind,from=toolbox_stage,target=/toolbox \ /toolbox/usr/bin/adduser-ssh --ssh-key gh:exampleuser --sudo-nopasswd exampleuser ``` Note that anythign after `--` is passed through to `useradd` so the user is still flexible.
48d2de5
to
03f10c1
Compare
This PR is stale because it has been open 30 days with no activity. Remove "Stale" label or comment or this will be closed in 7 days. |
Fwiw, I looked a bit around how to do this in a more upstream manner and while there was a suggestion to add it to "useradd" (c.f. shadow-maint/shadow#663) that was rejected on the grounds of "do-one-thing-and-do-it-well". |
This PR is stale because it has been open 30 days with no activity. Remove "Stale" label or comment or this will be closed in 7 days. |
This PR was closed because it has been stalled for 30+7 days with no activity. |
In various issue (e.g. https://gitlab.com/fedora/bootc/tracker/-/issues/2) and during devconf the idea of a
os-toolbox
(orsdk
,osbuild-sdk
,osbuild
,<insert-name-here>
got discussed). Broadly speaking there are two use-cases for this (quoting Colin here):bootc-image-builder
simplerOn my way back from devconf I was drafting a quick prototype for (1) with the user-creation in mind. I picked it because it seems the highest value target, i.e. user creation with ssh is a bit complicated right now and helping our users to get started more easily (and pleasantly) seems worthwhile.
Below is this prototype and an explanation how it works. It currently is part of the "bootc-iamge-builder" container but the code could live anywhere, I have no strong options here but it does seem sensible to me to have a
os-toolbox
(name strawman) that would contain both theuseradd-ssh
(orbootc-useradd
,adduser-ssh
or whatever we call it) and bib.Feedback very welcome. The code needs more unit tests (and input validation) but the added integration test is working for me within the limited scope (i.e. it does not build and image and boots/logins into it). I'm happy to flesh this out more once there is concensus that this is the right direction (and the right language as there is an argument for doing this in rust).
In order to add user with ssh keys to an bootc image a fairly complicated commandline is used today [0]:
With this commit this can be simplified to something like:
Note that anythign after
--
is passed through touseradd
so the user is still flexible.[edit: also note that the
--sudo-wheel-nopasswd
is not implemened yet and only there to illustrate the idea behind this helper][edit2: there is also https://gitlab.com/fedora/bootc/osbuild-cfg/ which is slightly different but has overlap]