【问题标题】:Is there any method for checking SFTP directory permission in Renci SSH.NET?Renci SSH.NET中有什么方法可以检查SFTP目录权限吗?
【发布时间】:2020-02-12 01:00:54
【问题描述】:

我想通过 SSH.NET 将文件上传到远程服务器。用户使用他们的 SSH 凭据登录。然后我问用户他们想把文件上传到哪里。然后我需要检查这个目录是否有读/写权限。

如何检查任何目录的读/写权限?

我尝试了SftpFile.OwnerCanWrite/OthersCanWrite/GroupCanWrite,但这些不适用于当前登录用户。

foreach (var directory in directories)
{
     if (!directory.Name.Equals(directoryName)) continue;

     // I want to check here if is there read/write permission.
}

【问题讨论】:

    标签: c# .net sftp ssh.net


    【解决方案1】:

    无法“检查” 使用 SFTP 协议的特定操作的实际(又名有效)权限。 SFTP API 不提供此类功能,也没有足够的信息供您自行决定。
    另见How to check for read permission using JSch with SFTP protocol?

    唯一的方法是实际尝试创建文件。例如。使用SftpClient.Create 方法。 毕竟,这就是你想要做的,不是吗?


    替代解决方案是 execute a shell commandtest -w path 来检查权限,而不是 SFTP。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-19
      • 2016-10-29
      • 2019-09-06
      • 2015-12-18
      • 2020-12-10
      • 2016-06-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多