Skip to content

templates: Disable SSH keys lookup from authorized_keys.d on FCOS#2087

Merged
openshift-merge-robot merged 1 commit intoopenshift:masterfrom
LorbusChris:rm-ssh-fragments
Nov 19, 2020
Merged

templates: Disable SSH keys lookup from authorized_keys.d on FCOS#2087
openshift-merge-robot merged 1 commit intoopenshift:masterfrom
LorbusChris:rm-ssh-fragments

Conversation

@LorbusChris
Copy link
Copy Markdown
Contributor

@LorbusChris LorbusChris commented Sep 15, 2020

- What I did
On FCOS, this sshd config dropin ensures that only SSH keys from the
/home/core/.ssh/authorized_keys file are picked up, and not ones
present in the /home/core/.ssh/authorized_keys.d/ directory,
which might be written by Ignition and/or Afterburn.

On RHCOS this is a no-op, as it already looks up SSH keys from the
authorized_keys file only.

- How to verify it
CI e2e testing

- Description for the changelog
templates: Disable SSH keys lookup from authorized_keys.d on FCOS

/hold
for testing

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 15, 2020
@LorbusChris
Copy link
Copy Markdown
Contributor Author

/cc @bgilbert

Copy link
Copy Markdown
Member

@ashcrow ashcrow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code makes sense 👍 . My only question is should this be done whenever update is called or should it be done once (bootstrap/firstboot)? I don't think it matters right now from the functionality perspective but still worth thinking about.

Copy link
Copy Markdown
Contributor

@bgilbert bgilbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only question is should this be done whenever update is called or should it be done once (bootstrap/firstboot)? I don't think it matters right now from the functionality perspective but still worth thinking about.

On some platforms, Afterburn may run on subsequent boots and recreate its fragment file.


Note that this PR makes a tradeoff: to avoid having to programmatically restart sshd, it disables authorized_keys.d at provisioning time. As a result, after an FCOS node first boots but before the MCO first syncs SSH keys, it will be impossible to SSH into the machine.

If we're comfortable with that tradeoff, there are a couple consequences:

  • Since we're disabling authorized_keys.d from a template, we don't actually need to remove the fragment files at all, except perhaps as documentation that they're not being used. On FCOS they'll never be read because of the sshd_config.d fragment. On RHCOS, we can simply not re-enable reading of .ssh/authorized_keys.d/ignition in sshd_config.
  • Furthermore, we could consider having Ignition on RHCOS continue to write the authorized_keys file directly. That would enable SSHing into an RHCOS node before the MCO SSH key sync runs, at the cost of divergent behavior between the OSes.

Comment thread templates/common/_base/files/sshd-disable-authorized-keys-command.yaml Outdated
Comment thread templates/common/_base/files/sshd-disable-authorized-keys-command.yaml Outdated
@ashcrow
Copy link
Copy Markdown
Member

ashcrow commented Sep 16, 2020

On some platforms, Afterburn may run on subsequent boots and recreate its fragment file.

Ah, great point 👍

@LorbusChris
Copy link
Copy Markdown
Contributor Author

@bgilbert updated, PTAL.

Copy link
Copy Markdown
Contributor

@bgilbert bgilbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LorbusChris Any thoughts on #2087 (review)? I see this version is still deleting the fragment files.

Comment thread templates/common/_base/files/sshd-disable-ssh-key-dir.yaml Outdated
@LorbusChris
Copy link
Copy Markdown
Contributor Author

@bgilbert if we're ok with Ignition continuing to write directly to /home/core/.ssh/authorized_keys on RHCOS we could indeed leave the files in the .d dir. I'll update.

On FCOS, this sshd config dropin ensures that only SSH keys from the
`/home/core/.ssh/authorized_keys` file are picked up, and not ones
present in the `/home/core/.ssh/authorized_keys.d/` directory,
which might be written by Ignition and/or Afterburn.

On RHCOS this is a no-op, as it already looks up SSH keys from the
authorized_keys file only.
@LorbusChris LorbusChris changed the title daemon: Disable and remove unmanaged SSH keys in authorized_keys.d templates: Disable SSH keys lookup from authorized_keys.d on FCOS Sep 24, 2020
Copy link
Copy Markdown
Contributor

@bgilbert bgilbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, provided we're okay with the tradeoffs in #2087 (review).

@cgwalters
Copy link
Copy Markdown
Member

Random aside, a lot of our thinking now is "rhcos == rhel8" but that will change - it's likely rhcos9 would potentially inherit any default changes we make to OpenSSH for example, so down the line ideally we'd do more "feature detection" rather than hardcode expectations that "rhcos" means a whole set of things.

Copy link
Copy Markdown
Member

@ashcrow ashcrow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM too ... cc @yuqi-zhang @runcom

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 25, 2020
@bgilbert
Copy link
Copy Markdown
Contributor

Random aside, a lot of our thinking now is "rhcos == rhel8" but that will change - it's likely rhcos9 would potentially inherit any default changes we make to OpenSSH for example

In this case there shouldn't be an issue. If future RHEL versions start reading sshd_config.d, this config fragment will be a no-op without the fragment it's overriding, and the latter is added by the ssh-key-dir package in fedora-coreos-base.yaml.

@ashcrow ashcrow requested a review from runcom September 28, 2020 16:07
@LorbusChris
Copy link
Copy Markdown
Contributor Author

/hold cancel
/retest

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 6, 2020
@openshift-ci-robot
Copy link
Copy Markdown
Contributor

@LorbusChris: The following tests failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/e2e-ovn-step-registry 5ed6fa3 link /test e2e-ovn-step-registry
ci/prow/okd-e2e-aws 5ed6fa3 link /test okd-e2e-aws

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@ashcrow
Copy link
Copy Markdown
Member

ashcrow commented Oct 23, 2020

/retest

1 similar comment
@LorbusChris
Copy link
Copy Markdown
Contributor Author

/retest

@LorbusChris
Copy link
Copy Markdown
Contributor Author

/cc @yuqi-zhang @runcom

@openshift-ci-robot openshift-ci-robot removed the request for review from ericavonb November 3, 2020 16:50
@openshift-bot
Copy link
Copy Markdown
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

6 similar comments
@openshift-bot
Copy link
Copy Markdown
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Copy Markdown
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Copy Markdown
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Copy Markdown
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Copy Markdown
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Copy Markdown
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@LorbusChris
Copy link
Copy Markdown
Contributor Author

/cherry-pick release-4.6

@openshift-cherrypick-robot
Copy link
Copy Markdown

@LorbusChris: once the present PR merges, I will cherry-pick it on top of release-4.6 in a new PR and assign it to you.

Details

In response to this:

/cherry-pick release-4.6

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-bot
Copy link
Copy Markdown
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

8 similar comments
@openshift-bot
Copy link
Copy Markdown
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Copy Markdown
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Copy Markdown
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Copy Markdown
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Copy Markdown
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Copy Markdown
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Copy Markdown
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Copy Markdown
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@LorbusChris
Copy link
Copy Markdown
Contributor Author

/refresh

@openshift-merge-robot
Copy link
Copy Markdown
Contributor

@LorbusChris: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/e2e-aws 5ed6fa3 link /test e2e-aws

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@LorbusChris
Copy link
Copy Markdown
Contributor Author

/retest

@openshift-cherrypick-robot
Copy link
Copy Markdown

@LorbusChris: new pull request created: #2245

Details

In response to this:

/cherry-pick release-4.6

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants