Skip to content

Commit

Permalink
Merge pull request dev-sec#278 from kostasns/issue_243
Browse files Browse the repository at this point in the history
feat: Allow to set custom list of HostKeyAlgorithms
  • Loading branch information
rndmh3ro committed May 8, 2020
2 parents eef6e11 + f8e5d36 commit ab5c108
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Warning: This role disables root-login on the target server! Please make sure yo
|`ssh_client_port` | '22' |port to which ssh-client should connect|
|`ssh_listen_to` | ['0.0.0.0'] |one or more ip addresses, to which ssh-server should listen to. Default is all adresseses, but should be configured to specific addresses for security reasons!|
|`ssh_host_key_files` | [] |Host keys for sshd. If empty ['/etc/ssh/ssh_host_rsa_key', '/etc/ssh/ssh_host_ecdsa_key', '/etc/ssh/ssh_host_ed25519_key'] will be used, as far as supported by the installed sshd version|
|`ssh_host_key_algorithms` | [] | Host key algorithms that the server offers. If empty the [default list](https://man.openbsd.org/sshd_config#HostKeyAlgorithms) will be used, otherwise overrides the setting with specified list of algorithms|
|`ssh_client_alive_interval` | 600 | specifies an interval for sending keepalive messages |
|`ssh_client_alive_count` | 3 | defines how often keep-alive messages are sent |
|`ssh_permit_tunnel` | false | true if SSH Port Tunneling is required |
Expand Down
3 changes: 3 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ ssh_listen_to: ['0.0.0.0'] # sshd
# Host keys to look for when starting sshd.
ssh_host_key_files: [] # sshd

# Specifies the host key algorithms that the server offers
ssh_host_key_algorithms: [] # sshd

# Specifies the maximum number of authentication attempts permitted per connection. Once the number of failures reaches half this value, additional failures are logged.
ssh_max_auth_retries: 2

Expand Down
5 changes: 5 additions & 0 deletions templates/opensshd.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ ListenAddress {{address}}
HostKey {{key}}
{% endfor %}

# Specifies the host key algorithms that the server offers.
{% if sshd_version is version('5.8', '>=') %}
{{ "HostKeyAlgorithms "+ssh_host_key_algorithms| join(',') if ssh_host_key_algorithms else "HostKeyAlgorithms"|comment }}
{% endif %}

# Security configuration
# ======================

Expand Down
5 changes: 5 additions & 0 deletions tests/default_custom.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@
ssh_authorized_principals_file: '/etc/ssh/auth_principals/%u'
ssh_authorized_principals:
- { path: '/etc/ssh/auth_principals/root', principals: [ 'root' ], owner: "{{ ssh_owner }}", group: "{{ ssh_group }}", directoryowner: "{{ ssh_owner }}", directorygroup: "{{ ssh_group}}" }
ssh_host_key_algorithms:
- ssh-ed25519
- rsa-sha2-512
- rsa-sha2-256
- ssh-rsa
ssh_macs:
- hmac-sha2-512
- hmac-sha2-256
Expand Down

0 comments on commit ab5c108

Please sign in to comment.