fix: SFTP err caused by known host key (#970)

Fixes #965
This commit is contained in:
lxdklp
2025-11-25 10:35:14 +08:00
committed by GitHub
parent 75d1a59e77
commit 141519d952
2 changed files with 8 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ class SftpReq {
String? privateKey;
Spi? jumpSpi;
String? jumpPrivateKey;
Map<String, String>? knownHostFingerprints;
SftpReq(this.spi, this.remotePath, this.localPath, this.type) {
final keyId = spi.keyId;
@@ -18,6 +19,11 @@ class SftpReq {
jumpSpi = Stores.server.box.get(spi.jumpId);
jumpPrivateKey = Stores.key.fetchOne(jumpSpi?.keyId)?.key;
}
try {
knownHostFingerprints = Map<String, String>.from(Stores.setting.sshKnownHostFingerprints.get());
} catch (_) {
knownHostFingerprints = null;
}
}
}

View File

@@ -65,6 +65,7 @@ Future<void> _download(SftpReq req, SendPort mainSendPort, SendErrorFunction sen
privateKey: req.privateKey,
jumpSpi: req.jumpSpi,
jumpPrivateKey: req.jumpPrivateKey,
knownHostFingerprints: req.knownHostFingerprints,
);
mainSendPort.send(SftpWorkerStatus.sshConnectted);
@@ -121,6 +122,7 @@ Future<void> _upload(SftpReq req, SendPort mainSendPort, SendErrorFunction sendE
privateKey: req.privateKey,
jumpSpi: req.jumpSpi,
jumpPrivateKey: req.jumpPrivateKey,
knownHostFingerprints: req.knownHostFingerprints,
);
mainSendPort.send(SftpWorkerStatus.sshConnectted);