Skip to content

Commit b12ee4d

Browse files
authored
ssh: Client HostKeyAlgorithms configuration variable (#442)
* ssh: Client HostKeyAlgorithms configuration variable Introduce a new variable ssh_client_host_key_algorithms to be able to configure it for the client like for the server. This fixes #441 Signed-off-by: Paul Seidler <[email protected]> * sshd: Adapt the ssh_host_key_algorithms description Linking to the latest version may lead to a broken config so be a bit more dynamic Signed-off-by: Paul Seidler <[email protected]>
1 parent 0f30ebf commit b12ee4d

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

roles/ssh_hardening/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ Warning: This role disables root-login on the target server! Please make sure yo
4040
- Description: Specifies the number of bits in the private host RSA key to create.
4141
- `ssh_host_key_algorithms`
4242
- Default: `[]`
43-
- Description: 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.
43+
- Description: Host key algorithms that the server offers. If empty the default list will be used. Otherwise overrides the setting with specified list of algorithms. Check `man sshd_config`, `ssh -Q HostKeyAlgorithms` or other sources for supported algorithms - make sure you check the correct version!
44+
- `ssh_client_host_key_algorithms`
45+
- Default: `[]`
46+
- Description: Specifies the host key algorithms that the client wants to use in order of preference. If empty the default list will be used. Otherwise overrides the setting with specified list of algorithms. Check `man ssh_config`, `ssh -Q HostKeyAlgorithms` or other sources for supported algorithms - make sure you check the correct version!.
4447
- `ssh_client_alive_interval`
4548
- Default: `600`
4649
- Description: specifies an interval for sending keepalive messages.

roles/ssh_hardening/defaults/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ ssh_host_certificates: [] # sshd
4545
# Specifies the host key algorithms that the server offers
4646
ssh_host_key_algorithms: [] # sshd
4747

48+
# Specifies the host key algorithms order the client will try
49+
ssh_client_host_key_algorithms: [] # ssh
50+
4851
# specifies the time allowed for successful authentication to the SSH server
4952
ssh_login_grace_time: 30s
5053

roles/ssh_hardening/templates/openssh.conf.j2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ StrictHostKeyChecking ask
8181
{# This outputs 'KexAlgorithms <list-of-algos>' if ssh_kex is defined or '#KexAlgorithms' if ssh_kex is undefined #}
8282
{{ 'KexAlgorithms ' ~ ssh_kex|join(',') if ssh_kex else 'KexAlgorithms'|comment }}
8383

84+
# Specifies the host key algorithms that the client wants to use in order of preference.
85+
{{ "HostKeyAlgorithms " ~ ssh_client_host_key_algorithms|join(',') if ssh_client_host_key_algorithms else "HostKeyAlgorithms"|comment }}
86+
8487
{% if sshd_version is version('5.9', '<') %}
8588
# Alternative setting, if OpenSSH version is below v5.9
8689
#MACs hmac-ripemd160

0 commit comments

Comments
 (0)