Skip to content

Commit 2067107

Browse files
committed
Add BOSH properties for configurable diego-sshd SSH algorithms
Add support for landscape operators to configure SSH algorithms for diego-sshd running in application containers. New BOSH properties under cc.diego.sshd (configured only in cloud_controller_ng): - allowed_ciphers: Comma separated list of allowed SSH cipher algorithms - allowed_host_key_algorithms: Comma separated list of allowed host key algorithms - allowed_key_exchanges: Comma separated list of allowed key exchange algorithms - allowed_macs: Comma separated list of allowed MAC algorithms All properties default to empty strings. When empty, diego-sshd uses its defaults. When configured, the comma-separated values are passed as command-line flags to diego-sshd. The properties are exposed via the cloud_controller_internal BOSH link and consumed by: - cloud_controller_worker - cloud_controller_clock - cc_deployment_updater
1 parent 9b863be commit 2067107

6 files changed

Lines changed: 73 additions & 1 deletion

File tree

jobs/cc_deployment_updater/templates/cloud_controller_ng.yml.erb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ diego:
128128
send_timeout: <%= p("cc.diego.bbs.send_timeout") %>
129129
receive_timeout: <%= p("cc.diego.bbs.receive_timeout") %>
130130
pid_limit: <%= p("cc.diego.pid_limit") %>
131+
sshd:
132+
allowed_ciphers: "<%= link("cloud_controller_internal").p("cc.diego.sshd.allowed_ciphers") %>"
133+
allowed_host_key_algorithms: "<%= link("cloud_controller_internal").p("cc.diego.sshd.allowed_host_key_algorithms") %>"
134+
allowed_key_exchanges: "<%= link("cloud_controller_internal").p("cc.diego.sshd.allowed_key_exchanges") %>"
135+
allowed_macs: "<%= link("cloud_controller_internal").p("cc.diego.sshd.allowed_macs") %>"
131136

132137
default_app_memory: <%= p("cc.default_app_memory") %>
133138
default_app_disk_in_mb: <%= p("cc.default_app_disk_in_mb") %>

jobs/cloud_controller_clock/templates/cloud_controller_ng.yml.erb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,11 @@ diego:
350350
send_timeout: <%= p("cc.diego.bbs.send_timeout") %>
351351
receive_timeout: <%= p("cc.diego.bbs.receive_timeout") %>
352352
pid_limit: <%= p("cc.diego.pid_limit") %>
353+
sshd:
354+
allowed_ciphers: "<%= link("cloud_controller_internal").p("cc.diego.sshd.allowed_ciphers") %>"
355+
allowed_host_key_algorithms: "<%= link("cloud_controller_internal").p("cc.diego.sshd.allowed_host_key_algorithms") %>"
356+
allowed_key_exchanges: "<%= link("cloud_controller_internal").p("cc.diego.sshd.allowed_key_exchanges") %>"
357+
allowed_macs: "<%= link("cloud_controller_internal").p("cc.diego.sshd.allowed_macs") %>"
353358

354359
<% if p("routing_api.enabled") %>
355360
routing_api:

jobs/cloud_controller_ng/spec

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,10 @@ provides:
241241
- cc.droplets.connection_config
242242
- cc.buildpacks.connection_config
243243
- cc.storage_cli_optional_flags
244+
- cc.diego.sshd.allowed_ciphers
245+
- cc.diego.sshd.allowed_host_key_algorithms
246+
- cc.diego.sshd.allowed_key_exchanges
247+
- cc.diego.sshd.allowed_macs
244248

245249
consumes:
246250
- name: database
@@ -1277,6 +1281,19 @@ properties:
12771281
description: "Maximum pid limit for containerized work running user-provided code"
12781282
default: 1024
12791283

1284+
cc.diego.sshd.allowed_ciphers:
1285+
description: "Comma separated list of allowed SSH cipher algorithms for diego-sshd. If empty, diego-sshd will use its defaults."
1286+
default: ""
1287+
cc.diego.sshd.allowed_host_key_algorithms:
1288+
description: "Comma separated list of allowed SSH host key algorithms for diego-sshd. If empty, diego-sshd will use its defaults."
1289+
default: ""
1290+
cc.diego.sshd.allowed_key_exchanges:
1291+
description: "Comma separated list of allowed SSH key exchange algorithms for diego-sshd. If empty, diego-sshd will use its defaults."
1292+
default: ""
1293+
cc.diego.sshd.allowed_macs:
1294+
description: "Comma separated list of allowed SSH MAC algorithms for diego-sshd. If empty, diego-sshd will use its defaults."
1295+
default: ""
1296+
12801297
cc.logcache.host:
12811298
description: "Hostname of the Logcache server"
12821299
default: doppler.service.cf.internal

jobs/cloud_controller_ng/templates/cloud_controller_ng.yml.erb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,11 @@ diego:
560560
enable_declarative_asset_downloads: <%= p("cc.diego.enable_declarative_asset_downloads") %>
561561
use_privileged_containers_for_running: <%= p("cc.diego.use_privileged_containers_for_running") %>
562562
use_privileged_containers_for_staging: <%= p("cc.diego.use_privileged_containers_for_staging") %>
563+
sshd:
564+
allowed_ciphers: "<%= p("cc.diego.sshd.allowed_ciphers") %>"
565+
allowed_host_key_algorithms: "<%= p("cc.diego.sshd.allowed_host_key_algorithms") %>"
566+
allowed_key_exchanges: "<%= p("cc.diego.sshd.allowed_key_exchanges") %>"
567+
allowed_macs: "<%= p("cc.diego.sshd.allowed_macs") %>"
563568

564569
perm:
565570
enabled: false

jobs/cloud_controller_worker/templates/cloud_controller_ng.yml.erb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,11 @@ diego:
329329
send_timeout: <%= p("cc.diego.bbs.send_timeout") %>
330330
receive_timeout: <%= p("cc.diego.bbs.receive_timeout") %>
331331
pid_limit: <%= p("cc.diego.pid_limit") %>
332+
sshd:
333+
allowed_ciphers: "<%= link("cloud_controller_internal").p("cc.diego.sshd.allowed_ciphers") %>"
334+
allowed_host_key_algorithms: "<%= link("cloud_controller_internal").p("cc.diego.sshd.allowed_host_key_algorithms") %>"
335+
allowed_key_exchanges: "<%= link("cloud_controller_internal").p("cc.diego.sshd.allowed_key_exchanges") %>"
336+
allowed_macs: "<%= link("cloud_controller_internal").p("cc.diego.sshd.allowed_macs") %>"
332337

333338
<% if p("routing_api.enabled") %>
334339
routing_api:

spec/cloud_controller_ng/cloud_controller_ng_spec.rb

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,13 @@ module Test
3333
'username' => 'blobstore-user' } },
3434
'diego' =>
3535
{
36-
'file_server_url' => 'http://somewhere'
36+
'file_server_url' => 'http://somewhere',
37+
'sshd' => {
38+
'allowed_ciphers' => '',
39+
'allowed_host_key_algorithms' => '',
40+
'allowed_key_exchanges' => '',
41+
'allowed_macs' => ''
42+
}
3743
},
3844
'database_encryption' =>
3945
{ 'skip_validation' => false,
@@ -533,6 +539,35 @@ module Test
533539
end
534540
end
535541

542+
describe 'diego.sshd config' do
543+
it 'defaults to empty strings' do
544+
template_hash = YAML.safe_load(template.render(merged_manifest_properties, consumes: links))
545+
expect(template_hash['diego']['sshd']['allowed_ciphers']).to eq('')
546+
expect(template_hash['diego']['sshd']['allowed_host_key_algorithms']).to eq('')
547+
expect(template_hash['diego']['sshd']['allowed_key_exchanges']).to eq('')
548+
expect(template_hash['diego']['sshd']['allowed_macs']).to eq('')
549+
end
550+
551+
context 'when SSH algorithms are configured' do
552+
before do
553+
merged_manifest_properties['cc']['diego']['sshd'] = {
554+
'allowed_ciphers' => 'cipher-1,cipher-2',
555+
'allowed_host_key_algorithms' => 'hostkeyalg-1,hostkeyalg-2',
556+
'allowed_key_exchanges' => 'kex-1,kex-2',
557+
'allowed_macs' => 'mac-1,mac-2'
558+
}
559+
end
560+
561+
it 'renders the configured SSH algorithms' do
562+
template_hash = YAML.safe_load(template.render(merged_manifest_properties, consumes: links))
563+
expect(template_hash['diego']['sshd']['allowed_ciphers']).to eq('cipher-1,cipher-2')
564+
expect(template_hash['diego']['sshd']['allowed_host_key_algorithms']).to eq('hostkeyalg-1,hostkeyalg-2')
565+
expect(template_hash['diego']['sshd']['allowed_key_exchanges']).to eq('kex-1,kex-2')
566+
expect(template_hash['diego']['sshd']['allowed_macs']).to eq('mac-1,mac-2')
567+
end
568+
end
569+
end
570+
536571
describe 'broker_client_max_async_poll_interval_seconds config' do
537572
it 'defaults to 86400 seconds' do
538573
template_hash = YAML.safe_load(template.render(merged_manifest_properties, consumes: links))

0 commit comments

Comments
 (0)