【问题标题】:Setting the extended file attributes using SSH.NET SftpClient使用 SSH.NET SftpClient 设置扩展文件属性
【发布时间】:2018-07-19 02:48:31
【问题描述】:

在我使用 Renci SSH.NET SFTP 库从 Windows 将文件上传到远程机器(Ubuntu 16.04 LTS)后,我正在尝试使用扩展文件属性来存储一些信息。但是属性没有得到保留?

这就是我尝试设置扩展属性的方式

SftpFileAttributes fileAttrs = sftpClient.GetAttributes(remoteFilePath);
IDictionary<string, string> additionalAttrs = new Dictionary<string, string>();
additionalAttrs.Add(new KeyValuePair<string, string>("user.from", "abc"));
additionalAttrs.Add(new KeyValuePair<string, string>("user.to", "xyz"));
fileAttrs =
    new SftpFileAttributes(
        fileAttrs.LastAccessTime, fileAttrs.LastWriteTime, fileAttrs.Size,
        fileAttrs.UserId, fileAttrs.GroupId, 222, additionalAttrs);
sftpClient.SetAttributes(remoteFilePath, fileAttrs);

那么,您能帮我解决这个问题吗? 注意:出于安全原因,远程计算机配置为仅允许 SFTP 连接。

【问题讨论】:

    标签: c# .net sftp openssh ssh.net


    【解决方案1】:

    您不能添加像user.from 这样的随机扩展属性。您只能添加您的服务器明确支持的属性。

    您没有指定您使用的 SFTP 服务器。但是当您连接到 Ubuntu 服务器时,可以假设它是最普遍的 *nix SFTP 服务器 OpenSSH。而且 OpenSSH 不支持任何扩展属性。它默默地忽略所有这些。


    另见这些讨论:

    以及SFTP规范的相关部分:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-02-10
      • 2013-07-20
      • 2011-01-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多