Skip to content
This repository was archived by the owner on Dec 26, 2020. It is now read-only.

Commit 9255b22

Browse files
authored
Merge pull request #278 from kostasns/issue_243
feat: Allow to set custom list of HostKeyAlgorithms
2 parents e1688e4 + 0fdafae commit 9255b22

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Warning: This role disables root-login on the target server! Please make sure yo
2222
|`ssh_client_port` | '22' |port to which ssh-client should connect|
2323
|`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!|
2424
|`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|
25+
|`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|
2526
|`ssh_client_alive_interval` | 600 | specifies an interval for sending keepalive messages |
2627
|`ssh_client_alive_count` | 3 | defines how often keep-alive messages are sent |
2728
|`ssh_permit_tunnel` | false | true if SSH Port Tunneling is required |

defaults/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ ssh_listen_to: ['0.0.0.0'] # sshd
3030
# Host keys to look for when starting sshd.
3131
ssh_host_key_files: [] # sshd
3232

33+
# Specifies the host key algorithms that the server offers
34+
ssh_host_key_algorithms: [] # sshd
35+
3336
# Specifies the maximum number of authentication attempts permitted per connection. Once the number of failures reaches half this value, additional failures are logged.
3437
ssh_max_auth_retries: 2
3538

templates/opensshd.conf.j2

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ ListenAddress {{address}}
3535
HostKey {{key}}
3636
{% endfor %}
3737

38+
# Specifies the host key algorithms that the server offers.
39+
{% if sshd_version is version('5.8', '>=') %}
40+
{{ "HostKeyAlgorithms "+ssh_host_key_algorithms| join(',') if ssh_host_key_algorithms else "HostKeyAlgorithms"|comment }}
41+
{% endif %}
42+
3843
# Security configuration
3944
# ======================
4045

tests/default_custom.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@
7979
ssh_authorized_principals_file: '/etc/ssh/auth_principals/%u'
8080
ssh_authorized_principals:
8181
- { path: '/etc/ssh/auth_principals/root', principals: [ 'root' ], owner: "{{ ssh_owner }}", group: "{{ ssh_group }}", directoryowner: "{{ ssh_owner }}", directorygroup: "{{ ssh_group}}" }
82+
ssh_host_key_algorithms:
83+
- ssh-ed25519
84+
- rsa-sha2-512
85+
- rsa-sha2-256
86+
- ssh-rsa
8287
ssh_macs:
8388
- hmac-sha2-512
8489
- hmac-sha2-256

0 commit comments

Comments
 (0)