This repository was archived by the owner on Dec 26, 2020. It is now read-only.
Fix ssh config to handle custom options per Host #83
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Example problem
Currently, a config such as
ssh_remote_hosts: ['host1', 'host2']
would yield this inssh_config
:Let's check the resulting
PasswordAuthentication
per host.host2
is the only host to benefit from the secure ssh options set in this role. All other hosts would use the insecure defaults (e.g., including Ciphers, MACs, Kex, etc.).Proposed fix
Given that the purpose of this role is to create more secure ssh defaults for all hosts, I figure
ssh_remote_hosts
was intended as a place for users specify a few custom options that differ from the new secure defaults.This PR changes the handling of
ssh_remote_hosts
such that a variable definition such as this...... would produce this in the
ssh_config
...That way all hosts get all the secure ssh defaults of this role, and users may specify custom overrides in
ssh_remote_hosts
.Notes
I believe this change does not affect tests in dev-sec/ssh-baseline's current
controls/ssh_spec.rb
.However, changing the structure of the
ssh_remote_hosts
variable would be a breaking change for users with any definition other thanssh_remote_hosts: []
. They would see templating errors unless they understand they must restructure theirssh_remote_hosts
variable.Maybe that error would be important as a way to call users' attention to the fact that their current
ssh_remote_hosts
may not be functioning as they expect. Or perhaps you would prefer to give a new name to this restructured variable, e.g.,ssh_options_per_host
.I believe the problem addressed in this PR is also present in dev-sec/chef-ssh-hardening and dev-sec/puppet-ssh-hardening.