aboutsummaryrefslogtreecommitdiff
path: root/src/remote.rs
diff options
context:
space:
mode:
authorakbash <akbash@herdr.dev>2026-09-08 03:34:54 +0300
committerGitHub <noreply@github.com>2026-09-08 03:34:54 +0300
commit9e01168b140ce8e3821131345dc82bc2bf9994eb (patch)
tree482832a0af8e79ea30f2ea4dcadbd874ac7fdb1d /src/remote.rs
parent792b2baa447a3ed413cc755ea3d76582021c648a (diff)
fix: show ssh errors during machine setup (#3733)
refs #3731 Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com>
Diffstat (limited to 'src/remote.rs')
-rw-r--r--src/remote.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/remote.rs b/src/remote.rs
index ba935ec4..4ab4d531 100644
--- a/src/remote.rs
+++ b/src/remote.rs
@@ -19,6 +19,16 @@ pub(crate) fn run_remote_client_bridge() -> std::io::Result<()> {
))
}
+pub(crate) fn print_saved_ssh_error_hint(err: &std::io::Error, target: &str) {
+ if is_remote_host_key_error(err) {
+ eprintln!(
+ "hint: saved machines use strict host-key checking; add the host key to the configured known_hosts file, then retry."
+ );
+ } else {
+ print_remote_error_hint(err, target);
+ }
+}
+
pub(crate) fn print_remote_error_hint(err: &std::io::Error, target: &str) {
if is_remote_auth_error(err) {
eprintln!(
@@ -31,6 +41,12 @@ pub(crate) fn print_remote_error_hint(err: &std::io::Error, target: &str) {
}
}
+fn is_remote_host_key_error(err: &std::io::Error) -> bool {
+ let message = err.to_string().to_ascii_lowercase();
+ message.contains("host key verification failed")
+ || message.contains("remote host identification has changed")
+}
+
fn is_remote_auth_error(err: &std::io::Error) -> bool {
let message = err.to_string();
message.contains("Permission denied")
@@ -64,6 +80,19 @@ mod tests {
use super::*;
#[test]
+ fn remote_host_key_error_matches_ssh_diagnostics() {
+ for message in [
+ "Host key verification failed.",
+ "REMOTE HOST IDENTIFICATION HAS CHANGED!",
+ ] {
+ assert!(is_remote_host_key_error(&std::io::Error::other(message)));
+ }
+ assert!(!is_remote_host_key_error(&std::io::Error::other(
+ "server closed connection"
+ )));
+ }
+
+ #[test]
fn remote_auth_error_matches_ssh_auth_denied() {
let err = std::io::Error::other(
"remote platform detection failed: user@host: Permission denied (publickey).",