MyGit

2016.1.0-beta3

sshnet/SSH.NET

版本发布时间: 2017-09-21 03:33:24

sshnet/SSH.NET最新发布版本:2024.1.0(2024-06-28 15:06:08)

Changes

ScpClient

A RemotePathTransformation property has been added to ScpClient that can be used to change if and how a remote path is transformed before it is passed to the scp command on the remote server.

SSH.NET comes with the following path transformations that are exposed through the RemotePathTransformation class (in Renci.SshNet):

When none of the built-in transformations match the specific requirements of a remote host, a custom transformation can be supplied.

More information on this change is available here.

Fixes issues #256 and #108.

Example:

Download a file using SCP, and apply shell quoting to the remote path:

using Renci.SshNet;

public class Program
{
  static void Main()
  {
      using (var client = new ScpClient("HOST", 22, "USER", "PWD"))
      {
          client.RemotePathTransformation = RemotePathTransformation.ShellQuote;
          client.Connect();

          using (var ms = new MemoryStream())
          {
              client.Download("/home/sshnet/file 123", ms);
          }
      }
  }
}

Since we've configured ScpClient to use the ShellQuote transformation, the /home/sshnet/file 123 path will automatically be enclosed in single quotes.

The actual path that is passed to the scp command on the remote host is therefore '/home/sshnet/file 123'.

Breaking changes

ScpClient

The Upload(FileInfo fileInfo, String path) method in ScpClient now expects path to be the remote path of the file to which you want to upload, and throws a ScpException if a directory exists on the remote host for that path (issue #286).

Up until now, uploading a file with a given (remote) path could lead a different result depending on whether a directory for that path exits on the remote host.

Example:

  using (var client = new ScpClient("host", "user", "pwd"))
  {
      client.Connect();

      client.Upload(new FileInfo(@"c:\temp\newlog.txt", "/home/sshnet/log");
  }

As of version 2016.1.0-beta3 a ScpException will be thrown when /home/sshnet/log exists as a directory on the remote host.

In previous versions of SSH.NET this code would actually upload the content of the c:\temp\newlog.txt file to /home/sshnet/log/newlog.txt.

When /home/sshnet/log exists on the remote host as a file or does not exist at all, the content of the c:\temp\newlog.txt file will be uploaded to /home/sshnet/log. This has not changed.

Fixes

ScpClient

SftpClient

SshClient

相关地址:原始地址 下载(tar) 下载(zip)

1、 SSH.NET-2016.1.0-beta3-bin.zip 2.11MB

2、 SSH.NET-2016.1.0-beta3-help.chm 2.3MB

查看:2017-09-21发行的版本