From 7dfecc7073c7ff7890bcc5d02f0f23fa1a537e47 Mon Sep 17 00:00:00 2001 From: Marius Thesing Date: Sat, 21 Mar 2026 12:48:47 +0100 Subject: [PATCH] Trying to repro Rekeying issue #1764 --- test/Renci.SshNet.IntegrationTests/Dockerfile | 1 + .../SftpClientTest.Upload.cs | 20 +++++++++++++++++++ .../SshdConfig.cs | 1 + 3 files changed, 22 insertions(+) diff --git a/test/Renci.SshNet.IntegrationTests/Dockerfile b/test/Renci.SshNet.IntegrationTests/Dockerfile index e5cc128b8..a762b0fd8 100644 --- a/test/Renci.SshNet.IntegrationTests/Dockerfile +++ b/test/Renci.SshNet.IntegrationTests/Dockerfile @@ -18,6 +18,7 @@ RUN apk update && apk upgrade --no-cache && \ # Set the default RSA key echo 'HostKey /etc/ssh/ssh_host_rsa_key' >> /etc/ssh/sshd_config && \ echo 'TrustedUserCAKeys /etc/ssh/user-ca.pub' >> /etc/ssh/sshd_config && \ + echo 'RekeyLimit 1M 0' >> /etc/ssh/sshd_config && \ chmod 646 /etc/ssh/sshd_config && \ # install and configure sudo apk add --no-cache sudo && \ diff --git a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.Upload.cs b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.Upload.cs index 40c296c7f..a598e452c 100644 --- a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.Upload.cs +++ b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.Upload.cs @@ -482,5 +482,25 @@ public async Task Test_Sftp_UploadFileAsync_UploadProgress() Assert.IsTrue(callbackCalled); } } + +#if NET + [TestMethod] + public async Task Test_SftpUpload_WithLowRekeyLimit() + { + using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password)) + { + await sftp.ConnectAsync(CancellationToken.None); + + await Parallel.ForEachAsync(Enumerable.Range(0, 10), async (i, ct) => + { + var filename = Path.GetTempFileName(); + int testFileSizeMB = 100; + CreateTestFile(filename, testFileSizeMB); + using var fileStream = File.OpenRead(filename); + await sftp.UploadFileAsync(fileStream, "test" + i, ct); + }); + } + } +#endif } } diff --git a/test/Renci.SshNet.TestTools.OpenSSH/SshdConfig.cs b/test/Renci.SshNet.TestTools.OpenSSH/SshdConfig.cs index 17f88dabd..54ad7ac85 100644 --- a/test/Renci.SshNet.TestTools.OpenSSH/SshdConfig.cs +++ b/test/Renci.SshNet.TestTools.OpenSSH/SshdConfig.cs @@ -426,6 +426,7 @@ private static void ProcessGlobalOption(SshdConfig sshdConfig, string line) case "PasswordAuthentication": case "GatewayPorts": case "Include": + case "RekeyLimit": break; default: throw new NotSupportedException($"Global option '{name}' is not supported.");