mirror of
https://github.com/veeso/termscp.git
synced 2026-09-27 06:21:22 -07:00
126 new feature termscp doesnt use id rsa default ssh private key to authenticate to sftp scp endpoint (#144)
fixed issue 126 <https://github.com/veeso/termcp/issues/126>
This commit is contained in:
committed by
veeso
parent
efd2235ff3
commit
251b125cbb
@@ -1,6 +1,7 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
- [Changelog](#changelog)
|
- [Changelog](#changelog)
|
||||||
|
- [0.11.0](#0110)
|
||||||
- [0.10.0](#0100)
|
- [0.10.0](#0100)
|
||||||
- [0.9.0](#090)
|
- [0.9.0](#090)
|
||||||
- [0.8.2](#082)
|
- [0.8.2](#082)
|
||||||
@@ -26,6 +27,19 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## 0.11.0
|
||||||
|
|
||||||
|
Released on ??
|
||||||
|
|
||||||
|
> 🦥 The lazy update
|
||||||
|
|
||||||
|
- **Bugfix**:
|
||||||
|
- Fixed [Issue 126](https://github.com/veeso/termscp/issues/126)
|
||||||
|
- Fixed [Issue 141](https://github.com/veeso/termscp/issues/141)
|
||||||
|
- Dependencies:
|
||||||
|
- Bump `remotefs-ssh` to `0.1.3`
|
||||||
|
- Bump `ssh2-config` to `0.1.4`
|
||||||
|
|
||||||
## 0.10.0
|
## 0.10.0
|
||||||
|
|
||||||
Released on 15/10/2022
|
Released on 15/10/2022
|
||||||
|
|||||||
Generated
+4
-4
@@ -2070,9 +2070,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "remotefs-ssh"
|
name = "remotefs-ssh"
|
||||||
version = "0.1.2"
|
version = "0.1.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "190106b53b839cf094172d2f1bc14e8d2846a69de06b239f11c2fc353080e9e0"
|
checksum = "8bcccc51bbdd0d32e1d3ab7076edd03943a195a267809cbceba6ec40e9d54f93"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
@@ -2548,9 +2548,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ssh2-config"
|
name = "ssh2-config"
|
||||||
version = "0.1.3"
|
version = "0.1.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "23ab9de63060578308d874ed89c9e362884506cb7f7f9e350af4dd3679ac321a"
|
checksum = "36ab5061c49144b158574b19c0e19d21ae97bed7f7bcf438dfe21fa27a46b633"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dirs",
|
"dirs",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
|
|||||||
+3
-3
@@ -54,7 +54,7 @@ rpassword = "^7.0"
|
|||||||
self_update = { version = "^0.32", default-features = false, features = [ "rustls", "archive-tar", "archive-zip", "compression-flate2", "compression-zip-deflate" ] }
|
self_update = { version = "^0.32", default-features = false, features = [ "rustls", "archive-tar", "archive-zip", "compression-flate2", "compression-zip-deflate" ] }
|
||||||
serde = { version = "^1", features = [ "derive" ] }
|
serde = { version = "^1", features = [ "derive" ] }
|
||||||
simplelog = "^0.12"
|
simplelog = "^0.12"
|
||||||
ssh2-config = "^0.1.3"
|
ssh2-config = "^0.1.4"
|
||||||
tempfile = "^3.2"
|
tempfile = "^3.2"
|
||||||
thiserror = "^1"
|
thiserror = "^1"
|
||||||
toml = "^0.5"
|
toml = "^0.5"
|
||||||
@@ -77,12 +77,12 @@ with-keyring = [ "keyring" ]
|
|||||||
[target."cfg(target_family = \"windows\")"]
|
[target."cfg(target_family = \"windows\")"]
|
||||||
[target."cfg(target_family = \"windows\")".dependencies]
|
[target."cfg(target_family = \"windows\")".dependencies]
|
||||||
remotefs-ftp = { version = "^0.1.2", features = [ "native-tls" ] }
|
remotefs-ftp = { version = "^0.1.2", features = [ "native-tls" ] }
|
||||||
remotefs-ssh = "^0.1.2"
|
remotefs-ssh = "^0.1.3"
|
||||||
|
|
||||||
[target."cfg(target_family = \"unix\")"]
|
[target."cfg(target_family = \"unix\")"]
|
||||||
[target."cfg(target_family = \"unix\")".dependencies]
|
[target."cfg(target_family = \"unix\")".dependencies]
|
||||||
remotefs-ftp = { version = "^0.1.2", features = [ "vendored", "native-tls" ] }
|
remotefs-ftp = { version = "^0.1.2", features = [ "vendored", "native-tls" ] }
|
||||||
remotefs-ssh = { version = "^0.1.2", features = [ "ssh2-vendored" ] }
|
remotefs-ssh = { version = "^0.1.3", features = [ "ssh2-vendored" ] }
|
||||||
users = "0.11.0"
|
users = "0.11.0"
|
||||||
|
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ mod tests {
|
|||||||
|
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::io::{Seek, SeekFrom};
|
use std::io::Seek;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use tuirealm::tui::style::Color;
|
use tuirealm::tui::style::Color;
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ use ssh2_config::SshConfig;
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
pub struct SshKeyStorage {
|
pub struct SshKeyStorage {
|
||||||
/// Association between {user}@{host} and RSA key path
|
/// Association between {user}@{host} and RSA key path
|
||||||
hosts: HashMap<String, PathBuf>,
|
hosts: HashMap<String, PathBuf>,
|
||||||
@@ -18,15 +19,6 @@ pub struct SshKeyStorage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl SshKeyStorage {
|
impl SshKeyStorage {
|
||||||
/// Create an empty ssh key storage; used in case `ConfigClient` is not available
|
|
||||||
#[cfg(test)]
|
|
||||||
pub fn empty() -> Self {
|
|
||||||
SshKeyStorage {
|
|
||||||
hosts: HashMap::new(),
|
|
||||||
ssh_config: None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Make mapkey from host and username
|
/// Make mapkey from host and username
|
||||||
fn make_mapkey(host: &str, username: &str) -> String {
|
fn make_mapkey(host: &str, username: &str) -> String {
|
||||||
format!("{username}@{host}")
|
format!("{username}@{host}")
|
||||||
@@ -61,16 +53,15 @@ impl SshKeyStorage {
|
|||||||
|
|
||||||
/// Resolve host via ssh2 configuration
|
/// Resolve host via ssh2 configuration
|
||||||
fn resolve_host_in_ssh2_configuration(&self, host: &str) -> Option<PathBuf> {
|
fn resolve_host_in_ssh2_configuration(&self, host: &str) -> Option<PathBuf> {
|
||||||
if let Some(config) = self.ssh_config.as_ref() {
|
self.ssh_config.as_ref().and_then(|x| {
|
||||||
let params = config.query(host);
|
let key = x
|
||||||
params
|
.query(host)
|
||||||
.identity_file
|
.identity_file
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|x| x.get(0).cloned())
|
.and_then(|x| x.get(0).cloned());
|
||||||
} else {
|
|
||||||
debug!("ssh2 config is not available; no key has been found");
|
key
|
||||||
None
|
})
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,7 +76,9 @@ impl SshKeyStorageTrait for SshKeyStorage {
|
|||||||
username, host
|
username, host
|
||||||
);
|
);
|
||||||
// otherwise search in configuration
|
// otherwise search in configuration
|
||||||
self.resolve_host_in_ssh2_configuration(host)
|
let key = self.resolve_host_in_ssh2_configuration(host)?;
|
||||||
|
debug!("Found key in SSH config for {host}: {}", key.display());
|
||||||
|
Some(key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,13 +179,13 @@ Host test
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_system_sshkey_storage_empty() {
|
fn test_system_sshkey_storage_empty() {
|
||||||
let storage: SshKeyStorage = SshKeyStorage::empty();
|
let storage: SshKeyStorage = SshKeyStorage::default();
|
||||||
assert_eq!(storage.hosts.len(), 0);
|
assert_eq!(storage.hosts.len(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_system_sshkey_storage_add() {
|
fn test_system_sshkey_storage_add() {
|
||||||
let mut storage: SshKeyStorage = SshKeyStorage::empty();
|
let mut storage: SshKeyStorage = SshKeyStorage::default();
|
||||||
storage.add_key("deskichup", "veeso", PathBuf::from("/tmp/omar"));
|
storage.add_key("deskichup", "veeso", PathBuf::from("/tmp/omar"));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
*storage.resolve("deskichup", "veeso").unwrap(),
|
*storage.resolve("deskichup", "veeso").unwrap(),
|
||||||
|
|||||||
Reference in New Issue
Block a user