From 205d2813ad0407a23999ea8f212c6d7ef25a7ad3 Mon Sep 17 00:00:00 2001 From: veeso Date: Sat, 20 Sep 2025 18:13:20 +0200 Subject: [PATCH] perf: Migrated to libssh.org on Linux and MacOS for better ssh agent support. closes #337 --- CHANGELOG.md | 1 + Cargo.lock | 26 ++++++++++++++++++++++++++ Cargo.toml | 5 ++++- src/filetransfer/remotefs_builder.rs | 10 +++++++--- 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 014616f..a7ab1ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ Released on 20/09/2025 - [Issue 356](https://github.com/veeso/termscp/issues/356): Fixed SSH auth issue not trying with the password if any RSA key was found. - [Issue 334](https://github.com/veeso/termscp/issues/334): SMB support for MacOS with vendored build of libsmbclient. +- [Issue 337](https://github.com/veeso/termscp/issues/337): Migrated to libssh.org on Linux and MacOS for better ssh agent support. ## 0.18.0 diff --git a/Cargo.lock b/Cargo.lock index 6ebfc98..0d06111 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2574,6 +2574,31 @@ dependencies = [ "redox_syscall", ] +[[package]] +name = "libssh-rs" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3066e110d6bb95a5addbd9c2ee595efdaeecaddd4793f3803dfee2968a74c685" +dependencies = [ + "bitflags 1.3.2", + "libc", + "libssh-rs-sys", + "openssl-sys", + "thiserror 1.0.69", +] + +[[package]] +name = "libssh-rs-sys" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d528ea9ac190fa364ff12193da82222dfc645e7ab28666ae91493bd288a1a0" +dependencies = [ + "cc", + "libz-sys", + "openssl-sys", + "pkg-config", +] + [[package]] name = "libssh2-sys" version = "0.3.1" @@ -3608,6 +3633,7 @@ checksum = "d29de4702886ae0e4433904d4f6f9b2ed2961d31d76a7e7bef58305097238eb6" dependencies = [ "chrono", "lazy-regex", + "libssh-rs", "log", "path-slash", "remotefs", diff --git a/Cargo.toml b/Cargo.toml index 2930fa5..e66b940 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -90,7 +90,10 @@ remotefs-ftp = { version = "^0.3", features = [ "native-tls-vendored", "native-tls", ] } -remotefs-ssh = { version = "^0.7", features = ["libssh2-vendored"] } +remotefs-ssh = { version = "^0.7", default-features = false, features = [ + "find", + "libssh-vendored", +] } uzers = "0.12" [target."cfg(target_family = \"windows\")".dependencies] diff --git a/src/filetransfer/remotefs_builder.rs b/src/filetransfer/remotefs_builder.rs index 3d9edd0..b52fb7c 100644 --- a/src/filetransfer/remotefs_builder.rs +++ b/src/filetransfer/remotefs_builder.rs @@ -13,7 +13,11 @@ use remotefs_kube::KubeMultiPodFs as KubeFs; use remotefs_smb::SmbOptions; #[cfg(smb)] use remotefs_smb::{SmbCredentials, SmbFs}; -use remotefs_ssh::{LibSsh2Session, ScpFs, SftpFs, SshAgentIdentity, SshConfigParseRule, SshOpts}; +#[cfg(windows)] +use remotefs_ssh::LibSsh2Session as SshSession; +#[cfg(unix)] +use remotefs_ssh::LibSshSession as SshSession; +use remotefs_ssh::{ScpFs, SftpFs, SshAgentIdentity, SshConfigParseRule, SshOpts}; use remotefs_webdav::WebDAVFs; #[cfg(not(smb))] @@ -141,7 +145,7 @@ impl RemoteFsBuilder { fn scp_client( params: GenericProtocolParams, config_client: &ConfigClient, - ) -> ScpFs { + ) -> ScpFs { Self::build_ssh_opts(params, config_client).into() } @@ -149,7 +153,7 @@ impl RemoteFsBuilder { fn sftp_client( params: GenericProtocolParams, config_client: &ConfigClient, - ) -> SftpFs { + ) -> SftpFs { Self::build_ssh_opts(params, config_client).into() }