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

ssh_config: Ignore pre-existing SSH keys on the client #14646

Merged
merged 1 commit into from
Sep 27, 2023
Merged

ssh_config: Ignore pre-existing SSH keys on the client #14646

merged 1 commit into from
Sep 27, 2023

Conversation

realdimas
Copy link
Contributor

Description

Make algo-generated ssh_config compatible with SSH client environments with six or more client keys defined.

Motivation and Context

sshd limits the number of authentication attempts permitted per established connection. The limit is set via the MaxAuthTries option and defaults to six attempts.

Client SSH environments that define more than six SSH keys globally or in the agent would exhaust authentication attempts before they reach the algo-specified per-instance SSH private key.

SSH client allows "forgetting" existing keys per connection using the IdentitiesOnly option.
A client only offers an explicitly defined key when this option is set.

How Has This Been Tested?

The change was tested via the -o IdentitiesOnly=yes CLI SSH option.

Before:
ssh -vF configs/192.0.2.2/ssh_config algo "echo loginokay" 2>&1 | egrep -i 'loginok|authentication|public'
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: [skipped] agent
debug1: Authentications that can continue: publickey
debug1: Offering public key: [skipped] agent
debug1: Authentications that can continue: publickey
debug1: Offering public key: [skipped] agent
debug1: Authentications that can continue: publickey
debug1: Offering public key: [skipped] agent
debug1: Authentications that can continue: publickey
debug1: Offering public key: [skipped] agent
debug1: Authentications that can continue: publickey
debug1: Offering public key: [skipped] agent
Received disconnect from 192.0.2.2 port 4160:2: Too many authentication failures

After:
ssh -o IdentitiesOnly=yes -vF configs/192.0.2.2/ssh_config algo "echo loginokay" 2>&1 | egrep -i 'loginok|authentication|public'
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: [skipped]/configs/algo.pem RSA SHA256:[skipped] explicit
Authenticated to 192.0.2.2 ([192.0.2.2]:4160) using "publickey".
debug1: Sending command: echo loginokay
loginokay

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

sshd limits the number of authentication attempts permitted per
established connection.
The limit is set via the MaxAuthTries option and defaults to six
attempts.

Client SSH environments that define more than six SSH keys globally or
in the agent would exhaust authentication attempts before they reach the
algo-specified per-instance SSH private key.

SSH client allows "forgetting" existing keys per connection using the
IdentitiesOnly option.
A client only offers an explicitly defined key when this option is set.
@CLAassistant
Copy link

CLAassistant commented Aug 26, 2023

CLA assistant check
All committers have signed the CLA.

@realdimas realdimas marked this pull request as ready for review August 26, 2023 20:09
@realdimas realdimas requested a review from jackivanov as a code owner August 26, 2023 20:09
@jackivanov jackivanov merged commit fd6efb7 into trailofbits:master Sep 27, 2023
@realdimas realdimas deleted the use-identitiesonly-ssh-client-option branch September 27, 2023 15:39
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.

3 participants