Skip to content

Commit 6b8cdbc

Browse files
committed
Refs #38478 - Introduce SSH cert support
1 parent 7a39054 commit 6b8cdbc

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

app/views/unattended/provisioning_templates/snippet/remote_execution_ssh_keys.erb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ description: |
1010
1111
remote_execution_ssh_keys: public keys to be put in ~/.ssh/authorized_keys
1212
13+
remote_execution_ssh_ca_keys: public ssh CA keys to be put in
14+
/etc/ssh/sshd_config.d/60-user-ca.conf
15+
1316
remote_execution_ssh_user: user for which remote_execution_ssh_keys will be
1417
authorized
1518
@@ -33,7 +36,7 @@ if [ -z "$PKG_MANAGER" ]; then
3336
<%= indent(2) { snippet 'pkg_manager' } -%>
3437
fi
3538

36-
<% if !host_param('remote_execution_ssh_keys').blank? %>
39+
<% if !host_param('remote_execution_ssh_keys').blank? || !host_param('remote_execution_ssh_ca_keys').blank? %>
3740
<% ssh_user = host_param('remote_execution_ssh_user') || 'root' %>
3841

3942
user_exists=false
@@ -64,6 +67,18 @@ EOF
6467
# Restore SELinux context with restorecon, if it's available:
6568
command -v restorecon && restorecon -RvF <%= ssh_path %> || true
6669

70+
<% if host_param('remote_execution_ssh_ca_keys').present? -%>
71+
cat << EOF >> /etc/ssh/user-ca.pub
72+
<%= host_param('remote_execution_ssh_ca_keys').is_a?(String) ? host_param('remote_execution_ssh_ca_keys') : host_param('remote_execution_ssh_ca_keys').join("\n") %>
73+
EOF
74+
75+
chmod 0644 /etc/ssh/user-ca.pub
76+
77+
mkdir -p /etc/ssh/sshd_config.d
78+
echo 'TrustedUserCAKeys /etc/ssh/user-ca.pub' >/etc/ssh/sshd_config.d/60-user-ca.conf
79+
systemctl restart sshd
80+
<% end -%>
81+
6782
<% if ssh_user != 'root' && host_param('remote_execution_effective_user_method') == 'sudo' -%>
6883
if [ ! -x "$(command -v sudo)" ]; then
6984
$PKG_MANAGER_INSTALL sudo

0 commit comments

Comments
 (0)