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

Don't always Enable SSHD and Open SSH Port [SLE-15-SP5] #1091

Merged
merged 12 commits into from
Jun 19, 2023

Conversation

shundhammer
Copy link
Contributor

@shundhammer shundhammer commented Jun 19, 2023

Target Branch

This is the merge of #1090 to SLE-15-SP5.

Bugzilla

https://bugzilla.suse.com/show_bug.cgi?id=1211764

Trello

https://trello.com/c/ofwfoQfm/

Problem

In the security proposal just before committing the installation, SSHD was always enabled, and the SSH port 22 was always opened by default, no matter if a root password was set or not.

If there is no root password, that makes sense since then it might be a case where only public key authentication was possible after the installation. But if a root password was set, it should not be the default to enable the SSHD service and open the SSH port.

Cause

This uses a class Installation::SecuritySettings which is meant to be used as a singleton. And as the singleton instance was used for the first time, all of its values were initialized, and those values were FINAL.

That included the values for opening the ssh port and the firewall. And as a fallback, if there was no root user yet, or the root password was empty, it assumed that there was only public key authentication, and in that case, it opened the SSH port and enabled SSHD.

The trouble was that all this happened BEFORE the user was even prompted for the root password, so at that point, of course the root password was still empty, so it always fell back to public key authentication.

Fix

This factors out the check if only public key authentication is configured to a new separate method SecuritySettings.propose and calls that method when the security proposal is made in the general proposal dialog ("Installation Settings") during the installation.

Test

Manual test in an inst-sys with the changed files bind-mounted on top. Selected different roles for the initial security settings; for any of the desktop roles (KDE, Gnome, Xfce), the SSH port should remain closed by default and no SSHD should be started, for the server roles they should.

Hacked up security_settings.rb a bit to pretend it's a public key only auth scenario when entering a trivial root password such as "root" and observed that it should also open the SSH port and enable SSHD in that case, but overriding it manually by clicking on those settings in the proposal needs to work (which should then give a warning):

sshd-warning

Related PRs

@coveralls
Copy link

Coverage Status

coverage: 40.657% (+0.04%) from 40.614% when pulling 07ec3d3 on huha-open-ssh-02-sp5 into 48826ac on SLE-15-SP5.

Copy link
Contributor

@teclator teclator left a comment

Choose a reason for hiding this comment

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

LGTM

@shundhammer shundhammer merged commit 5ed2d9b into SLE-15-SP5 Jun 19, 2023
@shundhammer shundhammer deleted the huha-open-ssh-02-sp5 branch June 19, 2023 08:50
@yast-bot
Copy link
Contributor

✔️ Internal Jenkins job #756 successfully finished
✔️ Created IBS submit request #301436

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.

4 participants