Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for the SSH ControlPath connection sharing option #713

Merged
merged 4 commits into from
Aug 24, 2023

Conversation

CarstenGrohmann
Copy link
Contributor

@CarstenGrohmann CarstenGrohmann commented Jun 28, 2023

OpenSSH multiplexing needs 3 configuration items:

  • ControlMaster
  • ControlPersist
  • ControlPath

Testinfra uses only the first two and this causes that connection multiplexing is not used:

DEBUG    testinfra:base.py:288 RUN CommandResult(command=b'ssh -o ControlMaster=auto -o ControlPersist=1200 -o ServerAliveInterval=180 -o StrictHostKeyChecking=no -o User=<reducted> -i \'~/.ssh/<reducted>\' -o ConnectTimeout=10 <reducted> \'sudo /bin/sh -c \'"\'"\'<reducted>\'"\'"\'\'', exit_status=0, stdout=b'<reducted>', stderr=None)

In comparison, Ansible uses all 3 parameters:

SSH: EXEC ssh -o ControlMaster=auto -o ControlPersist=1200 -o ServerAliveInterval=180 -o StrictHostKeyChecking=no -o StrictHostKeyChecking=no -o 'IdentityFile="<reducted>"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="<reducted>"' -o ConnectTimeout=10 -o 'ControlPath="<reducted>/.ansible/cp/%C"' <reducted>

With this change the third option to control connection sharing is introduced.

Share your thoughts, please.

OpenSSH multiplexing needs 3 configuration items:
* ControlMaster
* ControlPersist
* ControlPath

Testinfra uses only the first two and this causes that connection multiplexing is not used:

```
DEBUG    testinfra:base.py:288 RUN CommandResult(command=b'ssh -o ControlMaster=auto -o ControlPersist=1200 -o ServerAliveInterval=180 -o StrictHostKeyChecking=no -o User=<reducted> -i \'~/.ssh/<reducted>\' -o ConnectTimeout=10 <reducted> \'sudo /bin/sh -c \'"\'"\'<reducted>\'"\'"\'\'', exit_status=0, stdout=b'<reducted>', stderr=None)
```

In comparison, Ansible uses all 3 parameters:

```
SSH: EXEC ssh -o ControlMaster=auto -o ControlPersist=1200 -o ServerAliveInterval=180 -o StrictHostKeyChecking=no -o StrictHostKeyChecking=no -o 'IdentityFile="<reducted>"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="<reducted>"' -o ConnectTimeout=10 -o 'ControlPath="<reducted>/.ansible/cp/%C"' <reducted>
```

With this change the third option to control connection sharing is introduced.
testinfra/backend/ssh.py Outdated Show resolved Hide resolved
@philpep philpep merged commit 177947a into pytest-dev:main Aug 24, 2023
5 of 7 checks passed
@philpep
Copy link
Contributor

philpep commented Aug 24, 2023

Merged, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants