admin管理员组文章数量:1400089
I'm connecting to an SFTP Server with FileZilla and my app using the same credentials but for whatever reason, FileZilla will allow me to download files from that site but I'm getting a permission denied from my app when using Renci ssh.
The strange thing is that I can connect, recurse through folders, list all the files, get the file details via .NET, just not download.
The ssh code is bog standard but note that I've removed a load of validation, etc... for simplicity sake:
try
{
var sftpClient = this.GetSftpClient();
this.ChangeDirectory(sftpClient, remoteDirectory, false);
var file = sftpClient.Get(remoteFilename);
var fullOutputFilename = Path.Combine(outputPath, outputFilename);
try
{
using (var fileStream = System.IO.File.Create(fullOutputFilename))
{
sftpClient.DownloadFile(file.Name, fileStream);
}
}
catch (Exception ex)
{
Console.WriteLine($"Failed to open file: {file.FullName}");
Console.WriteLine($"Exception type: {ex.GetType().Name}");
Console.WriteLine($"Message: {ex.ToString()}");
}
Note that I can connect to that same SFTP site using PowerShell and when checking the file's permission, I get the following:
sftp> ls -l
-rwxrwxrwx 1 0 0 104278 Mar 20 17:11 MyFile.pdf
-rwxrwxrwx 1 0 0 1791 Mar 20 17:11 MyFile.json
Can you spot anything wrong with this? As far as I tell, all the permissions look ok to me.
I'm just getting the following exception:
Failed to open file: /MyFolder/Out/MySubfolder/MyFile.json
Exception type: SftpPermissionDeniedException
Message: Permission Denied....
Any ideas why this works from FileZilla, PowerShell but not with SSH.NET? Note that I've had this code working in the past where I'm using a private key file but in this instance, I need to use a username and password.
If I need to provide anything else, please let me know but note that I don't have access to the SFTP server as this is from a third-party company.
Thanks
版权声明:本文标题:c# - Can download file with Filezilla from SFTP server but getting permission denied from ssh.net - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744145693a2592824.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论