Add configurable option for paramiko banner_ssh timeout (#68184)

* Add configurable option for paramiko banner_ssh timeout

This PR adds a configurable option for paramiko connection
to control the value of banner timeout in paramiko library.
The banner timeout value can be set in ansible.cfg file as
The default value of banner timeout is set to 30 seconds in
paramiko connection plugin.
```
[paramiko_connection]
banner_timeout = 30
```
or using enviornment variable
```
export ANSIBLE_PARAMIKO_BANNER_TIMEOUT=30
```

* Fix CI failure

* Fix review comments

* Fix review comment
pull/78013/head
Ganesh Nalawade 2 years ago committed by GitHub
parent 570379ef98
commit 1b1c2c79cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -128,6 +128,20 @@ DOCUMENTATION = """
ini:
- section: defaults
key: use_persistent_connections
banner_timeout:
type: float
default: 30
description:
- Configures, in seconds, the amount of time to wait for the SSH
banner to be presented. This option is supported by paramiko
version 1.15.0 or newer.
ini:
- section: paramiko_connection
key: banner_timeout
version_added: '2.10'
env:
- name: ANSIBLE_PARAMIKO_BANNER_TIMEOUT
version_added: '2.10'
# TODO:
#timeout=self._play_context.timeout,
"""
@ -343,6 +357,10 @@ class Connection(ConnectionBase):
if LooseVersion(paramiko.__version__) >= LooseVersion('2.2.0'):
ssh_connect_kwargs['auth_timeout'] = self._play_context.timeout
# paramiko 1.15 introduced banner timeout parameter
if LooseVersion(paramiko.__version__) >= LooseVersion('1.15.0'):
ssh_connect_kwargs['banner_timeout'] = self.get_option('banner_timeout')
ssh.connect(
self._play_context.remote_addr.lower(),
username=self._play_context.remote_user,

Loading…
Cancel
Save