From c9382656098784c7d08097aad29305c5c0529fa5 Mon Sep 17 00:00:00 2001 From: Kate Case Date: Fri, 27 Oct 2023 18:15:03 -0400 Subject: [PATCH] Expose new libssh option publickey_accepted_algorithms --- docs/ansible.netcommon.libssh_connection.rst | 23 ++++++++++++++++++++ plugins/connection/libssh.py | 16 ++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/docs/ansible.netcommon.libssh_connection.rst b/docs/ansible.netcommon.libssh_connection.rst index 42a5b4628..14843cf4f 100644 --- a/docs/ansible.netcommon.libssh_connection.rst +++ b/docs/ansible.netcommon.libssh_connection.rst @@ -220,6 +220,29 @@ Parameters
TODO: write it
+ + +
+ publickey_accepted_algorithms + +
+ string +
+ + + Default:
""
+ + +
ini entries: +

[libssh_connection]
publickey_algorithms =

+
+
env:ANSIBLE_LIBSSH_PUBLICKEY_ALGORITHMS
+
var: ansible_libssh_publickey_algorithms
+ + +
List of algorithms to forward to SSH_OPTIONS_PUBLICKEY_ACCEPTED_TYPES.
+ +
diff --git a/plugins/connection/libssh.py b/plugins/connection/libssh.py index cd10a3a58..366df4763 100644 --- a/plugins/connection/libssh.py +++ b/plugins/connection/libssh.py @@ -100,6 +100,17 @@ - section: libssh_connection key: pty type: boolean + publickey_accepted_algorithms: + default: '' + description: + - List of algorithms to forward to SSH_OPTIONS_PUBLICKEY_ACCEPTED_TYPES. + type: string + env: + - name: ANSIBLE_LIBSSH_PUBLICKEY_ALGORITHMS + ini: + - {key: publickey_algorithms, section: libssh_connection} + vars: + - name: ansible_libssh_publickey_algorithms host_key_checking: description: 'Set this to "False" if you want to avoid host key checking by the underlying tools Ansible uses to connect to the host' type: boolean @@ -401,6 +412,11 @@ def _connect_uncached(self): "Please upgrade to ansible-pylibssh 1.0.0 or newer." % PYLIBSSH_VERSION ) + if self.get_option("publickey_accepted_algorithms"): + ssh_connect_kwargs["publickey_accepted_algorithms"] = self.get_option( + "publickey_accepted_algorithms" + ) + self.ssh.set_missing_host_key_policy(MyAddPolicy(self._new_stdin, self)) self.ssh.connect(