Skip to content

Commit dd530df

Browse files
QalthosNilashishC
andauthored
Expose new libssh option publickey_accepted_algorithms (#597)
* Expose new libssh option publickey_accepted_algorithms --------- Signed-off-by: NilashishC <[email protected]> Co-authored-by: NilashishC <[email protected]>
1 parent 35be779 commit dd530df

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
minor_changes:
3+
- "Exposes new libssh options to configure publickey_accepted_algorithms and hostkeys. This requires ansible-pylibssh v1.1.0 or higher."

docs/ansible.netcommon.libssh_connection.rst

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,29 @@ Parameters
108108
<div>Set this to &quot;False&quot; if you want to avoid host key checking by the underlying tools Ansible uses to connect to the host</div>
109109
</td>
110110
</tr>
111+
<tr>
112+
<td colspan="1">
113+
<div class="ansibleOptionAnchor" id="parameter-"></div>
114+
<b>hostkeys</b>
115+
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
116+
<div style="font-size: small">
117+
<span style="color: purple">string</span>
118+
</div>
119+
</td>
120+
<td>
121+
<b>Default:</b><br/><div style="color: blue">""</div>
122+
</td>
123+
<td>
124+
<div> ini entries:
125+
<p>[libssh_connection]<br>hostkeys = </p>
126+
</div>
127+
<div>env:ANSIBLE_LIBSSH_HOSTKEYS</div>
128+
<div>var: ansible_libssh_hostkeys</div>
129+
</td>
130+
<td>
131+
<div>Set the preferred server host key types as a comma-separated list (e.g., ssh-rsa,ssh-dss,ecdh-sha2-nistp256).</div>
132+
</td>
133+
</tr>
111134
<tr>
112135
<td colspan="1">
113136
<div class="ansibleOptionAnchor" id="parameter-"></div>
@@ -220,6 +243,29 @@ Parameters
220243
<div>TODO: write it</div>
221244
</td>
222245
</tr>
246+
<tr>
247+
<td colspan="1">
248+
<div class="ansibleOptionAnchor" id="parameter-"></div>
249+
<b>publickey_accepted_algorithms</b>
250+
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
251+
<div style="font-size: small">
252+
<span style="color: purple">string</span>
253+
</div>
254+
</td>
255+
<td>
256+
<b>Default:</b><br/><div style="color: blue">""</div>
257+
</td>
258+
<td>
259+
<div> ini entries:
260+
<p>[libssh_connection]<br>publickey_algorithms = </p>
261+
</div>
262+
<div>env:ANSIBLE_LIBSSH_PUBLICKEY_ALGORITHMS</div>
263+
<div>var: ansible_libssh_publickey_algorithms</div>
264+
</td>
265+
<td>
266+
<div>List of algorithms to forward to SSH_OPTIONS_PUBLICKEY_ACCEPTED_TYPES.</div>
267+
</td>
268+
</tr>
223269
<tr>
224270
<td colspan="1">
225271
<div class="ansibleOptionAnchor" id="parameter-"></div>

plugins/connection/libssh.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,27 @@
100100
- section: libssh_connection
101101
key: pty
102102
type: boolean
103+
publickey_accepted_algorithms:
104+
default: ''
105+
description:
106+
- List of algorithms to forward to SSH_OPTIONS_PUBLICKEY_ACCEPTED_TYPES.
107+
type: string
108+
env:
109+
- name: ANSIBLE_LIBSSH_PUBLICKEY_ALGORITHMS
110+
ini:
111+
- {key: publickey_algorithms, section: libssh_connection}
112+
vars:
113+
- name: ansible_libssh_publickey_algorithms
114+
hostkeys:
115+
default: ''
116+
description: Set the preferred server host key types as a comma-separated list (e.g., ssh-rsa,ssh-dss,ecdh-sha2-nistp256).
117+
type: string
118+
env:
119+
- name: ANSIBLE_LIBSSH_HOSTKEYS
120+
ini:
121+
- {key: hostkeys, section: libssh_connection}
122+
vars:
123+
- name: ansible_libssh_hostkeys
103124
host_key_checking:
104125
description: 'Set this to "False" if you want to avoid host key checking by the underlying tools Ansible uses to connect to the host'
105126
type: boolean
@@ -401,6 +422,14 @@ def _connect_uncached(self):
401422
"Please upgrade to ansible-pylibssh 1.0.0 or newer." % PYLIBSSH_VERSION
402423
)
403424

425+
if self.get_option("publickey_accepted_algorithms"):
426+
ssh_connect_kwargs["publickey_accepted_algorithms"] = self.get_option(
427+
"publickey_accepted_algorithms"
428+
)
429+
430+
if self.get_option("hostkeys"):
431+
ssh_connect_kwargs["hostkeys"] = self.get_option("hostkeys")
432+
404433
self.ssh.set_missing_host_key_policy(MyAddPolicy(self._new_stdin, self))
405434

406435
self.ssh.connect(

0 commit comments

Comments
 (0)