Skip to content

Commit 4b168dd

Browse files
committed
Fix an issue where users cannot SSH into LoginNodes with LoginNode-specific keys when different keys are specified for HeadNode and LoginNodes.
1 parent 54b9986 commit 4b168dd

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ This file is used to list changes made in each version of the AWS ParallelCluste
1212
**CHANGES**
1313
- Ubuntu 20.04 is no longer supported.
1414

15+
**BUG FIXES**
16+
- Fix an issue where users cannot SSH into LoginNodes with LoginNode-specific keys when different keys are specified for HeadNode and LoginNodes.
17+
1518
3.13.1
1619
------
1720

cookbooks/aws-parallelcluster-platform/recipes/config/cluster_user.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,40 @@
8989
shell '/bin/bash'
9090
end
9191

92+
directory node['cluster']['login_authorized_keys_dir'] do
93+
owner 'root'
94+
group 'root'
95+
mode '0755'
96+
end
97+
98+
directory "#{node['cluster']['login_authorized_keys_dir']}/#{node['cluster']['cluster_user']}" do
99+
owner node['cluster']['cluster_user']
100+
group node['cluster']['cluster_user']
101+
mode '0700'
102+
end
103+
104+
bash 'populate_login_node_local_key' do
105+
code <<-PERMS
106+
set -e
107+
cp #{node['cluster']['shared_dir_login_nodes']}/authorized_keys \
108+
#{node['cluster']['login_authorized_keys_dir']}/#{node['cluster']['cluster_user']}/authorized_keys
109+
chown #{node['cluster']['cluster_user']}:#{node['cluster']['cluster_user']} \
110+
#{node['cluster']['login_authorized_keys_dir']}/#{node['cluster']['cluster_user']}/authorized_keys
111+
chmod 0600 #{node['cluster']['login_authorized_keys_dir']}/#{node['cluster']['cluster_user']}/authorized_keys
112+
PERMS
113+
not_if { ::File.exist?("#{node['cluster']['login_authorized_keys_dir']}/#{node['cluster']['cluster_user']}/authorized_keys") }
114+
end
115+
116+
bash 'patch_sshd_config_for_login_nodes' do
117+
code <<-CONF
118+
set -e
119+
AUTH_DIR="#{node['cluster']['login_authorized_keys_dir']}/#{node['cluster']['cluster_user']}"
120+
LINE='AuthorizedKeysFile /etc/ssh/login_nodes_authorized_keys.d/%u/authorized_keys .ssh/authorized_keys'
121+
grep -q "${AUTH_DIR}/authorized_keys" /etc/ssh/sshd_config || echo "${LINE}" >> /etc/ssh/sshd_config
122+
CONF
123+
end
124+
125+
# keep the existing copy into /home for backward compatibility
92126
bash "copy_auth_file" do
93127
code <<-PERMS
94128
set -e

cookbooks/aws-parallelcluster-shared/attributes/cluster.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
default['cluster']['previous_cluster_config_path'] = "#{node['cluster']['shared_dir']}/previous-cluster-config.yaml"
2424
default['cluster']['login_cluster_config_path'] = "#{node['cluster']['shared_dir_login_nodes']}/cluster-config.yaml"
2525
default['cluster']['login_previous_cluster_config_path'] = "#{node['cluster']['shared_dir_login_nodes']}/previous-cluster-config.yaml"
26+
default['cluster']['login_authorized_keys_dir'] = '/etc/ssh/login_nodes_authorized_keys.d'
2627
default['cluster']['change_set_path'] = "#{node['cluster']['shared_dir']}/change-set.json"
2728
default['cluster']['instance_types_data_path'] = "#{node['cluster']['shared_dir']}/instance-types-data.json"
2829
default['cluster']['previous_instance_types_data_path'] = "#{node['cluster']['shared_dir']}/previous-instance-types-data.json"

0 commit comments

Comments
 (0)