Skip to content

Commit 92abac8

Browse files
authored
Merge pull request #388 from vollmerk/main
MODULES-11100 - Add sk-ecdsa public key support, and implement tests for sk-ecdsa and ecdsa keys
2 parents f29ee8b + 939d5d3 commit 92abac8

File tree

2 files changed

+35
-9
lines changed

2 files changed

+35
-9
lines changed

lib/puppet/functions/accounts_ssh_authorized_keys_line_parser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
end
1717

1818
def accounts_ssh_authorized_keys_line_parser_string(str)
19-
matched = str.match(%r{((ssh-|ecdsa-)[^\s]+)\s+([^\s]+)\s+(.*)$})
19+
matched = str.match(%r{((sk-ecdsa-|ssh-|ecdsa-)[^\s]+)\s+([^\s]+)\s+(.*)$})
2020
raise ArgumentError, 'Wrong Keyline format!' unless matched && matched.length == 5
2121
options = str[0, str.index(matched[0])].rstrip
2222
[options, matched[1], matched[3], matched[4]]

spec/acceptance/user_spec.rb

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,29 @@
55
test_key = 'AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8Hfd'\
66
'OV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9W'\
77
'hQ=='
8+
ecdsa_test_key = 'AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBNlpEm6+RwCiQXgQAb0P1asEAxCJDVtm/YYyUbdSifCbri98fjs1C/03pm9yLRQ0W/S70S8AhDCMjVFA07WzjOQ='
9+
ecdsa_sk_test_key = 'AAAAInNrLWVjZHNhLXNoYTItbmlzdHAyNTZAb3BlbnNzaC5jb20AAAAIbmlzdHAyNTYAAABBBAjkGvdKC05udQc82xGWWSKHbmJyBoa/oCq+2FiU6udqQyx0uOEC3YZAjvygBSdIo5vCpDELqJxaNQGQEkeUyYYAAAAEc3NoOg=='
810

911
pp_accounts_define = <<-PUPPETCODE
1012
file { '/test':
1113
ensure => directory,
1214
before => Accounts::User['hunner'],
1315
}
16+
if $facts['puppetversion'][0] == '6' {
17+
$key_test = [
18+
'ssh-rsa #{test_key} vagrant',
19+
'command="/bin/echo Hello",from="myhost.example.com,192.168.1.1" ssh-rsa #{test_key} vagrant2'
20+
]
21+
}
22+
else {
23+
$key_test = [#{' '}
24+
'ssh-rsa #{test_key} vagrant',
25+
'command="/bin/echo Hello",from="myhost.example.com,192.168.1.1" ssh-rsa #{test_key} vagrant2',
26+
'ecdsa-sha2-nistp256 #{ecdsa_test_key} vagrant3',
27+
'[email protected] #{ecdsa_sk_test_key} vagrant4'
28+
]
29+
}
30+
1431
accounts::user { 'hunner':
1532
groups => ['root'],
1633
password => 'hi',
@@ -20,10 +37,7 @@
2037
managevim => false,
2138
bashrc_content => file('accounts/shell/bashrc'),
2239
bash_profile_content => file('accounts/shell/bash_profile'),
23-
sshkeys => [
24-
'ssh-rsa #{test_key} vagrant',
25-
'command="/bin/echo Hello",from="myhost.example.com,192.168.1.1" ssh-rsa #{test_key} vagrant2'
26-
],
40+
sshkeys => $key_test,
2741
}
2842
PUPPETCODE
2943

@@ -41,6 +55,21 @@
4155
ensure => directory,
4256
before => Accounts::User['hunner'],
4357
}
58+
if $facts['puppetversion'][0] == '6' {
59+
$key_test = [
60+
'ssh-rsa #{test_key} vagrant',
61+
'command="/bin/echo Hello",from="myhost.example.com,192.168.1.1" ssh-rsa #{test_key} vagrant2'
62+
]
63+
}
64+
else {
65+
$key_test = [#{' '}
66+
'ssh-rsa #{test_key} vagrant',
67+
'command="/bin/echo Hello",from="myhost.example.com,192.168.1.1" ssh-rsa #{test_key} vagrant2',
68+
'ecdsa-sha2-nistp256 #{ecdsa_test_key} vagrant3',
69+
'[email protected] #{ecdsa_sk_test_key} vagrant4'
70+
]
71+
}
72+
4473
accounts::user { 'hunner':
4574
groups => ['root'],
4675
password => 'hi',
@@ -50,10 +79,7 @@
5079
managevim => true,
5180
bashrc_content => file('accounts/shell/bashrc'),
5281
bash_profile_content => file('accounts/shell/bash_profile'),
53-
sshkeys => [
54-
'ssh-rsa #{test_key} vagrant',
55-
'from="myhost.example.com,192.168.1.1" ssh-rsa #{test_key} vagrant2'
56-
],
82+
sshkeys => $key_test,
5783
}
5884
PUPPETCODE
5985

0 commit comments

Comments
 (0)