Skip to content
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

pkg/sshd: Remove default bind of /root/.ssh #3871

Merged
merged 1 commit into from
Nov 10, 2022

Conversation

the-maldridge
Copy link
Contributor

Signed-off-by: Michael Aldridge aldridge.mac@gmail.com

- What I did
Removed the default bind mount of /root/.ssh in the sshd package. When using the metadata package to summon keys, the ssh directory will not be present in root's home folder on the host filesystem because the keys are summoned dynamically. However, its not possible to just add the new bind for the authorized_keys file because the bind to the nonexistent directory prevents sshd from being able to start. This change removes the default bind since it can be trivially added back using binds.add for anyone who wishes to statically provide an authorized_keys file at build time.

- How I did it
A single elegant emacs command.

- How to verify it
Observe the diff, see that the bind mount is no longer present in build.yml.

- Description for the changelog
Remove /root/.ssh default bind to improve portability. Bind may be re-added with binds.add.

@deitch
Copy link
Collaborator

deitch commented Nov 9, 2022

I want to say that I am not sure I get this, but I am pretty sure I don't get this.

By default, it binds /root/.ssh. This is necessary because you need the system wide authorized_keys; don't want them in an ephemeral container.

I think you are saying that if /root/.ssh does not exist, then the container fails to start. Is that because the source dir for the bind is not there? Why not just make it a required directory?

@the-maldridge
Copy link
Contributor Author

I suppose you could make it a required directory, but that pushes the fix onto any user running ssh on linuxkit in the cloud, which feels like a kludge to me. By default it will bind /root/.ssh which would be great if this existed, but assuming that you aren't baking keys into images, you're likely fetching them with the metadata package, which writes them to /run/config since that's writeable and /etc/ isn't.

@deitch
Copy link
Collaborator

deitch commented Nov 9, 2022

So you are saying current design of linuxkit/sshd requires /root/.ssh; if it doesn't exist, sshd fails to start. Rather than having them automatically go to something that might or might not exist, do not define the mount, but be explicit in the docs about, "it looks for keys in /root/.ssh, bind mount that from where you want."

Is that it? If so, the docs and examples prob should reflect that as well.

@the-maldridge
Copy link
Contributor Author

Yeah that's pretty much it. If you think we can remove this mount if the docs are updated I will amend this PR to include docs changes.

@deitch
Copy link
Collaborator

deitch commented Nov 9, 2022

That sounds reasonable. We need any examples updated too.

Signed-off-by: Michael Aldridge <aldridge.mac@gmail.com>
@the-maldridge
Copy link
Contributor Author

I have amended my PR to include documentation on the metadata package. There didn't appear to be any documentation about sshd itself, but I can create some if you feel this is appropriate.

Some of the examples had conflicting behavior, so where there was question as to which key should be the active key I maintained whatever the previous behavior was. I think in general though it would be better to defer to the key from metadata as that is the established pattern for cloud providers.

@deitch deitch merged commit aa24821 into linuxkit:master Nov 10, 2022
@the-maldridge the-maldridge deleted the nobind branch November 10, 2022 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants