From 0d352e8ccf59d2e269d4be1ac6c1cdf52655484c Mon Sep 17 00:00:00 2001 From: nd Date: Sat, 12 Jun 2021 18:25:15 +0200 Subject: [PATCH] add support to define per host settings for the ssh client --- defaults/main.yml | 2 ++ templates/ssh_config.j2 | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/defaults/main.yml b/defaults/main.yml index bce5843..7d63a7a 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -15,3 +15,5 @@ ssh: MACs: hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,umac-128@openssh.com user: {} group: {} + client: + hosts: {} diff --git a/templates/ssh_config.j2 b/templates/ssh_config.j2 index dc0e350..ab36f9b 100644 --- a/templates/ssh_config.j2 +++ b/templates/ssh_config.j2 @@ -8,3 +8,11 @@ HostKeyAlgorithms ssh-ed25519-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com, KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group-exchange-sha256 MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,umac-128@openssh.com Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr +# add special rules for hosts defined in inventory variables + +{% for i in ssh.client.hosts %} +Host {{ i }} +{% for j in ssh.client.hosts[i]|d({}) %} + {{ j }}={{ ssh.client.hosts[i][j] }} +{% endfor %} +{% endfor %}