Search code examples
c#sshsftpfilesize

Renci SSH.NET: SftpClient.UploadFile fails to upload files greater than 1GB in size


I am using Renci .Net in C# in order to upload files to a Unix server (AIX) using SFTP, or to be more precise, I use the SftpClient.UploadFile method like this:

 using (Stream fileStream = sftp.OpenRead(file.FullName))
 {
     string remoteFileName = directory + @"/" + file.Name;
     try
     {
         sftp.UploadFile(fileStream, remoteFileName, true);
     }
     //...
  }

This works, as long as my files are 1GB in size or smaller. As soon as I upload a 2GB file, the process stops at exactly 1GB of transferred data. It soesn't hit the catch block, it simply stops.

Is this a known issue in Renci SSH.net? How can I fix it?


Solution

  • I finally figured out that this is not a limitation of Renci SSH.NET, but a setting of the Unix-Server I was trying to connect.

    I didn't think of that solution in first place, because uploading bigger files to that server using Samba worked.

    Obviously, it is possible to set different maximum allowed file sizes on that server for different connection types (Samba, sftp, ftp). After talking to the server admin, the allowed filesize was increased, and uploading big files using Renci SSH.NET works now. So in my case, the culprit was not Renci, but a server configuration.