From 09f1ab2cf2aff2cd966195fbde17525c275dff20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?lollipopkit=F0=9F=8F=B3=EF=B8=8F=E2=80=8D=E2=9A=A7?= =?UTF-8?q?=EF=B8=8F?= <10864310+lollipopkit@users.noreply.github.com> Date: Thu, 15 Jan 2026 20:09:33 +0800 Subject: [PATCH] fix --- lib/core/utils/server.dart | 23 ++++++++++++++++++++++- lib/data/model/sftp/worker.dart | 1 - 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/core/utils/server.dart b/lib/core/utils/server.dart index 70d48490..2d5283a7 100644 --- a/lib/core/utils/server.dart +++ b/lib/core/utils/server.dart @@ -504,20 +504,37 @@ Future ensureKnownHostKey( var cache = _loadKnownHostFingerprints(); final hops = resolveMergedJumpChain(spi); - for (final hop in hops) { + + // Check each hop's host key, routing through preceding hops + for (var i = 0; i < hops.length; i++) { + final hop = hops[i]; + // Preceding hops needed to reach this hop + final precedingHops = i > 0 ? hops.sublist(0, i) : null; + final precedingKeys = precedingHops?.map((h) => + h.keyId != null ? getPrivateKey(h.keyId!) : null + ).toList(); + cache = await _ensureKnownHostKeyForSingle( hop, cache: cache, timeout: timeout, onKeyboardInteractive: onKeyboardInteractive, + jumpChain: precedingHops, + jumpPrivateKeys: precedingKeys, ); } + // Check the target's host key, routing through all hops + final allKeys = hops.isNotEmpty + ? hops.map((h) => h.keyId != null ? getPrivateKey(h.keyId!) : null).toList() + : null; await _ensureKnownHostKeyForSingle( spi, cache: cache, timeout: timeout, onKeyboardInteractive: onKeyboardInteractive, + jumpChain: hops.isNotEmpty ? hops : null, + jumpPrivateKeys: allKeys, ); } @@ -526,6 +543,8 @@ Future> _ensureKnownHostKeyForSingle( required Map cache, Duration timeout = const Duration(seconds: 5), SSHUserInfoRequestHandler? onKeyboardInteractive, + List? jumpChain, + List? jumpPrivateKeys, }) async { if (_hasKnownHostFingerprintForSpi(spi, cache)) { return cache; @@ -536,6 +555,8 @@ Future> _ensureKnownHostKeyForSingle( timeout: timeout, onKeyboardInteractive: onKeyboardInteractive, knownHostFingerprints: cache, + jumpChain: jumpChain, + jumpPrivateKeys: jumpPrivateKeys, ); try { diff --git a/lib/data/model/sftp/worker.dart b/lib/data/model/sftp/worker.dart index 49ff885b..56466a38 100644 --- a/lib/data/model/sftp/worker.dart +++ b/lib/data/model/sftp/worker.dart @@ -7,7 +7,6 @@ import 'package:dartssh2/dartssh2.dart'; import 'package:easy_isolate/easy_isolate.dart'; import 'package:fl_lib/fl_lib.dart'; import 'package:server_box/core/utils/server.dart'; -import 'package:server_box/data/model/app/error.dart'; import 'package:server_box/data/model/server/server_private_info.dart'; import 'package:server_box/data/res/store.dart';