Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,9 @@ Thumbs.db

# Local-only scripts
/supabase.sql

# AI Coding 生成的提交文档
commit-info.md

# macOS 应用图标(二进制资源,单独提交)
resources/macos/OnetCli.icns
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions crates/core/src/storage/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ pub enum SshAuthMethod {
passphrase: Option<String>,
},
Agent,
AutoPublicKey,
}

/// Redis 连接模式
Expand Down Expand Up @@ -1052,4 +1053,13 @@ mod serial_tests {
serde_json::from_str(&json).expect("Agent 认证方式应可反序列化");
assert!(matches!(parsed, SshAuthMethod::Agent));
}

#[test]
fn ssh_auth_method_auto_publickey_serialize_deserialize() {
let auth = SshAuthMethod::AutoPublicKey;
let json = serde_json::to_string(&auth).expect("自动公钥认证方式应可序列化");
let parsed: SshAuthMethod =
serde_json::from_str(&json).expect("自动公钥认证方式应可反序列化");
assert!(matches!(parsed, SshAuthMethod::AutoPublicKey));
}
}
12 changes: 12 additions & 0 deletions crates/sftp/locales/sftp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ Sftp:
en: SSH agent authentication failed
zh-CN: SSH Agent 认证失败
zh-HK: SSH Agent 認證失敗
auth_auto_publickey_failed:
en: Automatic public key authentication failed
zh-CN: 自动公钥认证失败
zh-HK: 自動公鑰認證失敗
auth_no_local_identity:
en: No available local SSH identity was detected
zh-CN: 未检测到可用的本地 SSH 身份
zh-HK: 未檢測到可用的本地 SSH 身份
auth_auto_publickey_next_step:
en: Please load SSH Agent or switch to "Private Key" mode to specify a key file manually
zh-CN: 请加载 SSH Agent,或切换为「私钥文件」模式手动指定私钥
zh-HK: 請加載 SSH Agent,或切換為「私鑰文件」模式手動指定私鑰
socks5_proxy_connect_failed:
en: "SOCKS5 proxy connection failed: %{error}"
zh-CN: "SOCKS5代理连接失败: %{error}"
Expand Down
10 changes: 7 additions & 3 deletions crates/sftp/src/russh_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ use russh_sftp::client::rawsession::Limits;
use russh_sftp::protocol::{FileAttributes, OpenFlags, StatusCode};
use rust_i18n::t;
use ssh::{
AuthFailureMessages, ProxyConnectConfig, ProxyType, SshConnectConfig, authenticate_session,
AuthFailureMessages, ProxyConnectConfig, ProxyType, SshConnectConfig,
authenticate_with_strategy,
};
use std::collections::BTreeMap;
use std::sync::Arc;
Expand Down Expand Up @@ -54,6 +55,9 @@ fn sftp_auth_failure_messages() -> AuthFailureMessages {
agent_connect_failed: t!("Sftp.auth_agent_connect_failed").to_string(),
agent_no_identities: t!("Sftp.auth_agent_no_identities").to_string(),
agent_auth_failed: t!("Sftp.auth_agent_failed").to_string(),
auto_publickey_failed: t!("Sftp.auth_auto_publickey_failed").to_string(),
no_local_identity: t!("Sftp.auth_no_local_identity").to_string(),
auto_publickey_next_step: t!("Sftp.auth_auto_publickey_next_step").to_string(),
}
}

Expand Down Expand Up @@ -615,7 +619,7 @@ impl SftpClient for RusshSftpClient {
};

// 认证跳板机
authenticate_session(
authenticate_with_strategy(
&mut jump_session,
&jump.username,
&jump.auth,
Expand Down Expand Up @@ -648,7 +652,7 @@ impl SftpClient for RusshSftpClient {
};

// 认证目标服务器
authenticate_session(
authenticate_with_strategy(
&mut session,
&ssh_config.username,
&ssh_config.auth,
Expand Down
2 changes: 2 additions & 0 deletions crates/sftp_view/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ impl SftpView {
certificate_path: None,
},
SshAuthMethod::Agent => SshAuth::Agent,
SshAuthMethod::AutoPublicKey => SshAuth::AutoPublicKey,
};

let config = SshConnectConfig {
Expand All @@ -496,6 +497,7 @@ impl SftpView {
certificate_path: None,
},
SshAuthMethod::Agent => SshAuth::Agent,
SshAuthMethod::AutoPublicKey => SshAuth::AutoPublicKey,
};
JumpServerConnectConfig {
host: jump.host,
Expand Down
1 change: 1 addition & 0 deletions crates/ssh/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ async-trait = { workspace = true }
anyhow = { workspace = true }
tracing = { workspace = true }
rust-i18n = { workspace = true }
dirs.workspace = true
# SSH and SFTP
russh.workspace = true
# Proxy support
Expand Down
12 changes: 12 additions & 0 deletions crates/ssh/locales/ssh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ Ssh:
en: SSH agent authentication failed
zh-CN: SSH Agent 认证失败
zh-HK: SSH Agent 認證失敗
auth_auto_publickey_failed:
en: Automatic public key authentication failed
zh-CN: 自动公钥认证失败
zh-HK: 自動公鑰認證失敗
auth_no_local_identity:
en: No available local SSH identity was detected
zh-CN: 未检测到可用的本地 SSH 身份
zh-HK: 未檢測到可用的本地 SSH 身份
auth_auto_publickey_next_step:
en: Please load SSH Agent or switch to "Private Key" mode to specify a key file manually
zh-CN: 请加载 SSH Agent,或切换为「私钥文件」模式手动指定私钥
zh-HK: 請加載 SSH Agent,或切換為「私鑰文件」模式手動指定私鑰
socks5_proxy_connect_failed:
en: "SOCKS5 proxy connection failed: %{error}"
zh-CN: "SOCKS5代理连接失败: %{error}"
Expand Down
3 changes: 2 additions & 1 deletion crates/ssh/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ mod ssh;
pub use ssh::{
AuthFailureMessages, ChannelEvent, JumpServerConnectConfig, LocalPortForwardTunnel,
ProxyConnectConfig, ProxyType, PtyConfig, RusshChannel, RusshClient, SshAuth, SshChannel,
SshClient, SshConnectConfig, authenticate_session, start_local_port_forward,
SshClient, SshConnectConfig, authenticate_session, authenticate_session_with_fallbacks,
authenticate_with_strategy, expand_auto_publickey_auth, start_local_port_forward,
};
Loading
Loading