Skip to content

Refine SSH auth ordering and password fallback#144

Merged
skshetry merged 7 commits into
treeverse:mainfrom
shcheklein:fix-ssh-auth-ordering-kbdint-fallback
May 16, 2026
Merged

Refine SSH auth ordering and password fallback#144
skshetry merged 7 commits into
treeverse:mainfrom
shcheklein:fix-ssh-auth-ordering-kbdint-fallback

Conversation

@shcheklein
Copy link
Copy Markdown
Contributor

@shcheklein shcheklein commented Apr 23, 2026

Built on top of #143 and #141


This rewrites the earlier SSH password prompt fix around a narrower, protocol-aware auth selection strategy while keeping the keyboard-interactive password fallback fix.

Changes:

  • limit auth attempts to methods backed by configured credentials
  • prefer password,keyboard-interactive for password-based logins
  • prefer publickey when explicit key material is configured
  • keep configured passwords from falling back to interactive prompts
  • add focused tests for preferred_auth construction

This should address unnecessary publickey/passphrase prompts without breaking servers which expose password login only through keyboard-interactive.

@shcheklein shcheklein force-pushed the fix-ssh-auth-ordering-kbdint-fallback branch 2 times, most recently from 9538b1d to 5794215 Compare April 24, 2026 01:30
Comment thread dvc_ssh/__init__.py Outdated
if login_info.get("client_keys") or login_info.get("passphrase") is not None:
preferred_auth.append("publickey")
if login_info.get("password") is not None:
preferred_auth.extend(("password", "keyboard-interactive"))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be reverse, to match with asyncssh.

       :param preferred_auth:
           A list of authentication methods the client should attempt to
           use in order of preference. By default, the preferred list is
           gssapi-keyex, gssapi-with-mic, hostbased, publickey,
           keyboard-interactive, and then password. This list may be
           limited by which auth methods are implemented by the client
           and which methods the server accepts.

Suggested change
preferred_auth.extend(("password", "keyboard-interactive"))
preferred_auth.extend(("keyboard-interactive", "password"))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shcheklein, I think you need to also fix the assertions in the tests.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@skshetry please give it a try again

Comment thread dvc_ssh/tests/test_client.py Outdated
shcheklein and others added 3 commits May 13, 2026 13:35
Co-authored-by: skshetry <18718008+skshetry@users.noreply.github.com>
@shcheklein shcheklein requested a review from skshetry May 13, 2026 20:38
@skshetry skshetry merged commit 2c89653 into treeverse:main May 16, 2026
21 checks passed
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