Skip to content

fix(sftp): fix OpenSSH key auth and password fallback after asyncssh migration - #51

Closed
Orinks wants to merge 1 commit into
devfrom
fix/sftp-openssh-key-auth
Closed

fix(sftp): fix OpenSSH key auth and password fallback after asyncssh migration#51
Orinks wants to merge 1 commit into
devfrom
fix/sftp-openssh-key-auth

Conversation

@Orinks

@Orinks Orinks commented Mar 2, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #49 — regular OpenSSH key authentication broken after asyncssh migration.

Three bugs in SFTPClient.connect():

  • Password used as key passphrase unconditionally: the password field was always passed as passphrase to asyncssh.connect(), even for non-encrypted keys. Removed — passphrase is no longer set at all, letting asyncssh handle encrypted keys via its own KeyImportError path (already caught).
  • passphrase=None explicitly set: even when no password existed, passphrase=None was passed in kwargs. Now omitted entirely per asyncssh best practice.
  • No password fallback with key auth: elif prevented password from being passed alongside client_keys. Changed to separate if blocks so password auth works as fallback when key auth fails.

Also added a distinct PermissionDenied error message for the key+password case.

Test plan

  • test_connect_with_key_file — key-only: no passphrase or password in kwargs
  • test_connect_with_key_and_password_fallback — key+password: password kwarg set, no passphrase
  • test_connect_with_key_and_password_logs_both_methods — auth methods log includes both
  • test_auth_failure_message_for_key_and_password — error message mentions password fallback
  • All 93 existing protocol tests pass

🤖 Generated with Claude Code

…migration

Closes #49

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Orinks

Orinks commented Mar 2, 2026

Copy link
Copy Markdown
Owner Author

Closing — this PR introduces a regression where key-only auth (no password) stops working. Dev branch already handles key auth correctly. Issue #49 may be invalid.

@Orinks Orinks closed this Mar 2, 2026
@Orinks
Orinks deleted the fix/sftp-openssh-key-auth branch May 2, 2026 23:19
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.

1 participant