SSH.NET icon indicating copy to clipboard operation
SSH.NET copied to clipboard

Renci.SshNet.Common.SftpPathNotFoundException: No such file (in existing files)

Open insinfo opened this issue 3 years ago • 10 comments
trafficstars

I'm getting a lot of SftpPathNotFoundException errors, and the files exist because I can copy them via Powershell SCP and Filezilla

image

image

log

failed: /var/www/html/teste/marcos/poo/projeto1_antigo_com_tudo/cadCli - C?pia1.php | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec(ZipFile zip, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 90
failed: /var/www/html/teste/marcos/poo/projeto1_antigo_com_tudo/cadCli - C?pia2.php | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec(ZipFile zip, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 90
failed: /var/www/html/teste/marcos/C?pia de P_entrada1.csv | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec(ZipFile zip, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 90
failed: /var/www/html/teste/aline/SCS/Relat?rio de Testes SCS Seg Fase.pdf | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec(ZipFile zip, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 90
failed: /var/www/html/teste/aline/SCS/Relat?rio de Testes SCS - 2? fase.doc | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec(ZipFile zip, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 90
failed: /var/www/html/teste/aline/SCS/Relat?rio de Testes SCS.doc | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec(ZipFile zip, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 90
failed: /var/www/html/teste/aline/SCS/Relat?rio de Testes SCS.pdf | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec(ZipFile zip, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 90
...
Download File failed: /var/www/html/teste/marcos/poo/projeto1_antigo_com_tudo/cadCli - C?pia1.php | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 141
Download File failed: /var/www/html/teste/marcos/poo/projeto1_antigo_com_tudo/cadCli - C?pia2.php | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 141
Download File failed: /var/www/html/teste/marcos/C?pia de P_entrada1.csv | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 141
Download File failed: /var/www/html/teste/aline/SCS/Relat?rio de Testes SCS Seg Fase.pdf | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 141
Download File failed: /var/www/html/teste/aline/SCS/Relat?rio de Testes SCS - 2? fase.doc | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 141
Download File failed: /var/www/html/teste/aline/SCS/Relat?rio de Testes SCS.doc | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 141
Download File failed: /var/www/html/teste/aline/SCS/Relat?rio de Testes SCS.pdf | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 141
Download Directory failed: /var/www/html/teste/RAFAEL_PROJOVEM/teste/Introdu??o_php | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Sftp.SftpSession.RequestOpenDir(String path, Boolean nullOnError)
   at Renci.SshNet.SftpClient.InternalListDirectory(String path, Action`1 listCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 120
Download File failed: /var/www/html/DESENVnovosimco/imagens/C?pia de fundo_popup.jpg | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 141
Download File failed: /var/www/html/pop2019_antigo/WEB_op__C?pia 2.php | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 141
Download File failed: /var/www/html/Manual_do_SIME_para_Maca?.pdf | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 141
Download File failed: /var/www/html/DESENV_SCS/imagens/images/C?pia de print.gif | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in 
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 141
Download File failed: /var/www/html/saero/public_html_SAERO VELHO/teste/conteudo/xtra/ABDALLA 12?.csv | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at Co
....Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 141
Download File failed: /var/www/html/saero/public_html_SAERO VELHO/teste/conteudo/xtra/JO?O EJA.csv | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 141
Download File failed: /var/www/html/saero/public_html_SAERO VELHO/teste/conteudo/xtra/INAY? 410.csv | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 141
Download File failed: /var/www/html/saero/public_html_SAERO VELHO/teste/conteudo/xtra/INAY? 408.csv | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 141
Download File failed: /var/www/html/saero/public_html_SAERO VELHO/teste/conteudo/xtra/PROF? MARINETE 4? ano.csv | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 141
Download File failed: /var/www/html/saero/public_html_SAERO VELHO/teste/conteudo/xtra/PROF? MARINETE 7? ANO.csv | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 141
Download File failed: /var/www/html/saero/public_html_SAERO VELHO/teste/conteudo/xtra/M? Teixeira 903.csv | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 141
Download File failed: /var/www/html/saero/public_html_SAERO VELHO/teste/conteudo/xtra/MARIA TEIXEIRA 6? Ano.csv | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 141
Download File failed: /var/www/html/saero/public_html_SAERO VELHO/teste/conteudo/xtra/VER. PEDRO 7? ANO.csv | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 141
Download File failed: /var/www/html/saero/public_html_SAERO VELHO/teste/conteudo/xtra/Inay? 505.csv | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 141
Download File failed: /var/www/html/saero/public_html_SAERO VELHO/teste/conteudo/xtra/MARIA PENHA 14?.csv | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 141
Download File failed: /var/www/html/saero/public_html_SAERO VELHO/teste/conteudo/xtra/TRINDADE 5? ANO.csv | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 141
Download File failed: /var/www/html/saero/public_html_SAERO VELHO/teste/conteudo/xtra/FRANCISCO 8? ANO.csv | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 141
Download File failed: /var/www/html/saero/public_html_SAERO VELHO/teste/conteudo/xtra/MARIA PENHA 4? ano.csv | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 141
Download File failed: /var/www/html/saero/public_html_SAERO VELHO/teste/conteudo/xtra/SIMAR 4? ano.csv | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 141
Download File failed: /var/www/html/saero/public_html_SAERO VELHO/teste/conteudo/xtra/MARIA TEIXEIRA 7? ANO.csv | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 141
Download File failed: /var/www/html/saero/public_html_SAERO VELHO/teste/conteudo/xtra/INAY? 8? ANO.csv | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 141
Download File failed: /var/www/html/saero/public_html_SAERO VELHO/teste/conteudo/xtra/VER. PEDRO 8? ANO.csv | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 141
Download File failed: /var/www/html/saero/public_html_SAERO VELHO/teste/conteudo/xtra/FRANCISCO 9? ANO.csv | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 141
...
Download File failed: /var/www/html/pop2019/includes/C?_³pia de aux_qualify2.dbm | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 141
Download File failed: /var/www/html/pop2019/WEB_op__C?pia 2.php | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 141
Download Directory failed: /var/www/html/DESENVg2Ds/Pasta sem t?tulo | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Sftp.SftpSession.RequestOpenDir(String path, Boolean nullOnError)
   at Renci.SshNet.SftpClient.InternalListDirectory(String path, Action`1 listCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 120
Download File failed: /var/www/html/recall/online/C?pia de recadserv_pdf.php | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 141
end Download
Execution Time: 5864845 ms

O C:\MyCsharpProjects\fsbackup\bin\x64\Debug\net6.0\fsbackup.exe (processo 18832) foi encerrado com o código 0.
Para fechar o console automaticamente quando a depuração parar, habilite Ferramentas -> Opções -> Depuração -> Fechar o console automaticamente quando a depuração parar.
Pressione qualquer tecla para fechar esta janela...

static void Main(string[] args)
        {
            var watch = new System.Diagnostics.Stopwatch();
            watch.Start();

            var connectionInfo = new ConnectionInfo("192.168.2.77", "root",
                                        new PasswordAuthenticationMethod("root", "pass"));
            var client = new SftpClient(connectionInfo);            
            client.Connect();

            DownloadDirectoryAsZip2(client, "/var/www/html", @"C:\MyCsharpProjects\fsbackup\download.zip");
            client.Dispose();  

            Console.WriteLine("end Download");
            watch.Stop();
            Console.WriteLine($"Execution Time: {watch.ElapsedMilliseconds} ms");
        }
public static void DownloadDirectoryAsZip2(SftpClient sftpClient, string sourceRemotePath, string destLocalPath)
        {
            using (var zipFile = new FileStream(destLocalPath, FileMode.OpenOrCreate))
            {
                using (var archive = new ZipArchive(zipFile, ZipArchiveMode.Update))
                {
                    DownloadDirectoryAsZipRec2(archive, sftpClient, sourceRemotePath);                    
                }
            }                
        }
        private static void DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, string sourceRemotePath)
        {
            try
            {
                var files = sftpClient.ListDirectory(sourceRemotePath);
                foreach (var file in files)
                {
                    if ((file.Name != ".") && (file.Name != ".."))
                    {
                        var sourceFilePath = sourceRemotePath + "/" + file.Name;
                      
                        if (file.IsDirectory)
                        {
                            DownloadDirectoryAsZipRec2(archive, sftpClient, sourceFilePath);
                        }
                        else
                        {

                            //var memoryStream = new MemoryStream();
                            // var memoryStream = File.Create(Path.GetTempFileName(), 4096, FileOptions.DeleteOnClose);
                            ZipArchiveEntry entry = archive.CreateEntry(sourceFilePath);
                            using (Stream memoryStream = entry.Open()) { 

                                try
                                {
                                    sftpClient.DownloadFile(sourceFilePath, memoryStream);
                                }
                                catch (Exception e)
                                {
                                    Console.WriteLine($"Download File failed: {sourceFilePath} | Error:{e}");
                                }
                                
                            }
                        }
                    }
                }
            }catch (Exception e)
            {
                Console.WriteLine($"Download Directory failed: {sourceRemotePath} | Error:{e}");
            }
        }

insinfo avatar Apr 08 '22 18:04 insinfo

Could be an encoding issue. You don't happen to have a public server that we can reproduce this issue against?

drieseng avatar Apr 08 '22 18:04 drieseng

@drieseng Unfortunately I don't have any public server to make available, because the servers here are on an internal network, but I believe this can be replicated on any linux server with SSH/SFTP and Samba configured, I had this problem in rust and dart too when was implementing directory download via SCP my solution for this was to get the filename in Bytes[] instead of String I have this implemented here libssh_binding in dart I downloaded the files with the name in Bytes (Uint8List) instead of String and when saving I did a sanitization, but I don't know if there's a way to do the same thing in C# with SshNet

insinfo avatar Apr 08 '22 20:04 insinfo

@insinfo Can you translate the text regarding UTF-8 in your screenshot? You can could try to use another encoding (using ConnectionInfo.Encoding).

drieseng avatar Apr 09 '22 10:04 drieseng

I compressed one of the directories that is giving error with "tar -zcvf archive.tar.gz /var/www/html/teste/marcos/poo/" and attached it so you can try to replicate it.

archive.tar.gz

insinfo avatar Apr 11 '22 13:04 insinfo

With UTF8 and ASCII connectionInfo.Encoding = Encoding.UTF8; connectionInfo.Encoding = Encoding.ASCII;

Download File failed: /var/www/html/teste/marcos/poo/projeto1_antigo_com_tudo/cadCli - C?pia1.php | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Common.AsyncResult`1.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 147
Download File failed: /var/www/html/teste/marcos/poo/projeto1_antigo_com_tudo/cadCli - C?pia2.php | Error:Renci.SshNet.Common.SftpPathNotFoundException: No such file
   at Renci.SshNet.Common.AsyncResult.EndInvoke()
   at Renci.SshNet.Common.AsyncResult`1.EndInvoke()
   at Renci.SshNet.Sftp.SftpSession.EndOpen(SftpOpenAsyncResult asyncResult)
   at Renci.SshNet.ServiceFactory.CreateSftpFileReader(String fileName, ISftpSession sftpSession, UInt32 bufferSize)
   at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action`1 downloadCallback)
   at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action`1 downloadCallback)
   at ConsoleApp1.Program.DownloadDirectoryAsZipRec2(ZipArchive archive, SftpClient sftpClient, String sourceRemotePath) in C:\MyCsharpProjects\fsbackup\Program.cs:line 147

insinfo avatar Apr 11 '22 13:04 insinfo

Any update on this issue?

suryawanshi-rakesh avatar Apr 18 '23 06:04 suryawanshi-rakesh

For reference, in case anyone else runs into this: we were experiencing this with a particular SFTP server we were working with. The solution in our case was to set connectionInfo.Encoding = Encoding.GetEncoding("Windows-1252"). Depending on what the server you are connecting to, you might have to use something else (Windows-1252 is "Western European (Windows)"). This table has a more complete list of potential encodings: https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-text-encoding#list-of-encodings

TL;DR: to the best of my knowledge, SFTP transfers using SSH.NET works correctly in this regard, as long as you configure the correct encoding to be used for the connection.

perlun avatar May 23 '24 12:05 perlun

TL;DR: to the best of my knowledge, SFTP transfers using SSH.NET works correctly in this regard, as long as you configure the correct encoding to be used for the connection.

How to determine the correct encoding? Looking at the source code it's used to convert the file name into bytes to be sent to the server when opening a file. I'd assume the default option which is UTF-8 would be enough but I still get the error.

vborovikov avatar Sep 08 '25 13:09 vborovikov

@vborovikov That's a good question and my short answer would be "I don't know". But if we look in the original screenshot posted in this issue, it says "Recebida uma sequência de caracteres inválida, desabilitando UTF-8. Selecione a opção UTF-8 no Gerenciador de Sites para forçar o UTF-8." (thanks to ChatGPT who helped me convert the image to text). Translating this to English gives me something like "Received an invalid character sequence, disabling UTF-8. Select the UTF-8 option in Site Manager to force UTF-8."

Perhaps you could try connecting to the host in question using FileZilla and see if you get something similar? If yes, try with Windows-1252 or whatever "local encoding" that would be used in your region before UTF-8 became prevalent (e.g. perhaps koi8-r in a Russian/Cyrillic context - the page I linked to has a list of these pre-Unicode encodings).

perlun avatar Sep 12 '25 17:09 perlun

So in my case the issue was simple. Check your SFTP server's sshd_config file to see how ChrootDirectory option is set for the SFTP user group. Perhaps its value is %h which means that your SFTP user home directory is treated as the file system root. Change it to /, restart ssh service, and then you can access files using their full paths. Or bind mount required directories to your SFTP user home directory.

vborovikov avatar Sep 12 '25 18:09 vborovikov