Skip to content

feat(auth): use default ssh key path if field is not filled - #103

Merged
GOODBOY008 merged 1 commit into
GOODBOY008:mainfrom
supercute:feature/default-keypath-on-create-connection
Sep 2, 2026
Merged

feat(auth): use default ssh key path if field is not filled#103
GOODBOY008 merged 1 commit into
GOODBOY008:mainfrom
supercute:feature/default-keypath-on-create-connection

Conversation

@supercute

Copy link
Copy Markdown
Contributor

Closes #102

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds automatic SSH private-key discovery when no path is provided, supporting SSH and SFTP connections.

Changes:

  • Allows empty public-key paths in connection flows.
  • Resolves ~/.ssh/id_rsa or id_ed25519 automatically.
  • Centralizes cross-platform tilde expansion.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/App.tsx Relaxes selected credential checks.
src/components/connection-dialog.tsx Removes mandatory key-path validation.
src-tauri/src/commands.rs Resolves default keys for SSH/SFTP.
src-tauri/src/lib.rs Registers the key-path module.
src-tauri/src/os_keypath.rs Implements key discovery and path expansion.
src-tauri/src/sftp_client.rs Uses shared tilde expansion.
src-tauri/src/ssh/mod.rs Uses shared tilde expansion.
Suppressed comments (1)

src/App.tsx:590

  • The same catch-all causes saved SSH connections using the advertised keyboard-interactive method to bypass the credential dialog and call a backend that rejects that method. Only publickey should be considered credential-complete without a stored value here.
      : (connectionData.authMethod === 'password'
        ? !!connectionData.password
        : true);

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/App.tsx Outdated
: (connectionData.authMethod === 'password'
? !!connectionData.password
: !!connectionData.privateKeyPath);
: true)
Comment thread src/App.tsx Outdated
: connectionData.authMethod === 'password'
? !!connectionData.password
: (connectionData.authMethod === 'anonymous' ? true : !!connectionData.privateKeyPath);
: true; // Public-key auth can fallback to the default SSH key
/// Resolves the configured SSH private key path or falls back to the user's default key.
///
/// If no key path is provided, checks for `id_rsa` first, then `id_ed25519`.
pub fn resolve_private_key_path(key_path: Option<&str>) -> Result<String, String> {
@supercute
supercute force-pushed the feature/default-keypath-on-create-connection branch from afc2b6d to 49d59e8 Compare September 1, 2026 13:55
@supercute

Copy link
Copy Markdown
Contributor Author

@GOODBOY008 i added tests for os_keypath and move check credentials to connection-storage.ts

@supercute
supercute force-pushed the feature/default-keypath-on-create-connection branch from 49d59e8 to 3c87eed Compare September 1, 2026 14:01
@GOODBOY008
GOODBOY008 requested a balanced review from Copilot September 2, 2026 09:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Default-key selection can choose an unusable identity without trying another valid key, and explicit paths unnecessarily require a resolvable home directory.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 9/9 changed files
  • Comments generated: 2
  • Review effort level: Balanced

Comment on lines +6 to +9
pub fn resolve_private_key_path(key_path: Option<&str>) -> Result<String, String> {
let home = dirs::home_dir().ok_or_else(|| "Could not determine home directory".to_string())?;
resolve_private_key_path_with_home(key_path, &home)
}

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.

Ok, Copilot is right. Fixed this one

Comment on lines +18 to +23
for filename in ["id_rsa", "id_ed25519"] {
let candidate = ssh_dir.join(filename);
if candidate.is_file() {
return Ok(candidate.to_string_lossy().into_owned());
}
}

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.

I think existence doesn't imply authorization. I'm keeping the single attempt purposely: the fallback targets the common one-default-key setup, the failure is deterministic and names the exact key tried, and hosts with several keys can specify the path explicitly

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@supercute I add the failed key path to error msg and this will be useful to users.

@GOODBOY008

GOODBOY008 commented Sep 2, 2026

Copy link
Copy Markdown
Owner

@supercute I will resolve this conflicts.

@GOODBOY008
GOODBOY008 force-pushed the feature/default-keypath-on-create-connection branch 2 times, most recently from 7e38630 to d0d99b0 Compare September 2, 2026 13:35
1. Added connection-storage.ts for centralize credentical checks.
2. Added tests for os_keypath.rs and for connection-storage.ts

feat(auth): use default ssh key path if field is not filled
@GOODBOY008
GOODBOY008 force-pushed the feature/default-keypath-on-create-connection branch from d0d99b0 to afdaf2c Compare September 2, 2026 13:53

@GOODBOY008 GOODBOY008 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@supercute Thanks for your contributions, LGTM~

@GOODBOY008
GOODBOY008 merged commit 79c2b20 into GOODBOY008:main Sep 2, 2026
4 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.

Feature proposal: Use default public key path on create connection if field not filled

3 participants