Skip to content

Conversation

@adamlazik1
Copy link
Contributor

No description provided.

@adamlazik1
Copy link
Contributor Author

@adamlazik1 adamlazik1 changed the title Refs #38478 - Introduce SSH cert support Refs #38499 - Introduce SSH cert support Jun 16, 2025
@adamlazik1 adamlazik1 changed the title Refs #38499 - Introduce SSH cert support Fixes #38499 - Introduce SSH cert support Jun 16, 2025

mkdir -p /etc/ssh/sshd_config.d
echo 'TrustedUserCAKeys /etc/ssh/user-ca.pub' >/etc/ssh/sshd_config.d/60-user-ca.conf
systemctl restart sshd
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure you can always rely on being able to restart services. For example, I'm wondering about cloud-init.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not too familiar with cloud-init. Are you referring to the fact that cloud-init may change service configuration or may manipulate with services while it runs? I tried to make the service restart a bit more robust, please tell me if it works or if I need to take some different precautions with regards to cloud-init .

@adamlazik1 adamlazik1 force-pushed the ssh-cert-support branch 5 times, most recently from fc22a59 to 2e306fd Compare June 23, 2025 10:57
@adamlazik1
Copy link
Contributor Author

I will keep this in draft because there will be four PRs in total that should get merged at roughly the same time, but I do believe that this is now ready for review.

command -v restorecon && restorecon -RvF /etc/ssh || true

# restart the sshd service
$(command -v cloud-init && cloud-init status --wait) >/dev/null 2>&1 || true
Copy link
Contributor

Choose a reason for hiding this comment

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

What would happen if this fired from within cloud-init?

<%= indent(2) { snippet 'remote_execution_ssh_keys' } %>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It took me a while to get my provisioning setup working, but I found out that while the command does not hang and appears to be executed, the sshd service is not restarted. Same thing happens when I do not include the cloud-init line altegether. Currently I am looking into other possible ways to restart the service within cloud-init.

@adamlazik1
Copy link
Contributor Author

I don't know how I have done it before but after several days of trying different stuff I am unable to replicate cloud-init malfunction which I had before on the current version of the PR. The sshd service is now correctly restarted and ssh certs work out of the box. I see there is only one runcmd in our cloud-init template, so if I am not mistaken, no race conditions should be able to occur, correct?

@adamlazik1 adamlazik1 force-pushed the ssh-cert-support branch 3 times, most recently from bff3e1a to 1fd7a96 Compare July 11, 2025 06:59
@adamlazik1 adamlazik1 marked this pull request as ready for review July 11, 2025 06:59
@adamlazik1
Copy link
Contributor Author

Currently, this PR does not support configuring cert authentication on hosts that exist before the feature is enabled the smart proxy. Should I create a job template that could do this? It would have to be run before the ssh cert authentication is enabled on smart proxy.

@adamlazik1 adamlazik1 force-pushed the ssh-cert-support branch 3 times, most recently from 88ecbe9 to 0c01c2c Compare July 21, 2025 09:02
@adamlazik1
Copy link
Contributor Author

Switching back to draft since the feature got postponed to 3.16

Copy link
Contributor

@lhellebr lhellebr left a comment

Choose a reason for hiding this comment

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

I have been able to verify the SSH CA cert feature as a complex of the following 4 PRs:
theforeman/smart_proxy_remote_execution_ssh#126
#10571
theforeman/foreman_remote_execution#977
theforeman/puppet-foreman_proxy#867

Including the following use cases:
SSH REX
Ansible REX
Pull mode REX
Cockpit

Including hosts created by:
Global registration
Provisioning

Including scenarios:
SSH CA on Satellite side
SSH CA on host side
SSH CA on both sides

Both positive scenarios and negative scenarios, that is incorrect CA, incorrect cert, incorrect principal.

=> ACK to this PR

@adamruzicka
Copy link
Contributor

@adamlazik1 does this still need to be a draft?

@adamlazik1 adamlazik1 marked this pull request as ready for review December 18, 2025 09:35
@adamlazik1
Copy link
Contributor Author

/packit build

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants