feat(ssh): probe none authentication before credentials
Some SSH proxies and jump-hosts authenticate with the "none" method, requiring no password or key. dbx only tried publickey/password/agent, so connecting through such a host failed with "SSH public key authentication failed" — and the frontend forced users to enter a credential just to pass validation. - Backend: probe authenticate_none first in connect_and_authenticate; on rejection fall back to the configured credential method, matching standard openssh behavior. - Frontend: drop the "password/key/agent required" check in validateTransportLayers so passwordless hops can be saved and tested. Refs #1628
This commit is contained in:
1 parent
4b45912862
commit
849caf4b39
2 files changed
+19
-4
No files matched your search
@@ -77,6 +77,18 @@ async fn connect_and_authenticate(
|
||||
.map_err(|_| format!("SSH connection timed out ({connect_timeout_secs}s)"))?
|
||||
.map_err(|e| format!("SSH connection failed: {e}"))?;
|
||||
|
||||
// Probe with "none" authentication first. Some SSH proxies and jump-hosts
|
||||
// accept connections without any credential, and this is also the standard
|
||||
// SSH probe used to discover the auth methods the server supports.
|
||||
let none_res = tokio::time::timeout(connect_timeout, session.authenticate_none(ssh_user))
|
||||
.await
|
||||
.map_err(|_| format!("SSH auth probe timed out ({connect_timeout_secs}s)"))?
|
||||
.map_err(|e| format!("SSH auth probe failed: {e}"))?;
|
||||
if none_res.success() {
|
||||
return Ok(session);
|
||||
}
|
||||
|
||||
// "none" was rejected — fall back to the configured credential method.
|
||||
if !ssh_key_path.is_empty() {
|
||||
// Validate SSH key file path
|
||||
validate_file_path(ssh_key_path, |_| false)?;
|
||||
@@ -114,7 +126,10 @@ async fn connect_and_authenticate(
|
||||
Err(agent_err) => return Err(agent_err),
|
||||
}
|
||||
} else {
|
||||
return Err("No SSH authentication method provided (password, key, or ssh-agent)".to_string());
|
||||
return Err(
|
||||
"SSH authentication failed: \"none\" was rejected and no password, key, or ssh-agent is configured"
|
||||
.to_string(),
|
||||
);
|
||||
}
|
||||
|
||||
Ok(session)
|
||||
|
||||
Reference in new issue
Block a user