SSH.net - SSH 连接有效,但 SCP returns "incorrect username and password"

SSH.net - SSH connection works, but SCP returns "incorrect username and password"

假设我有一个连接 class,具有来自 SSH.net 库(由 Renci)的 SSHClient 和 SCPClient 的属性:

public class SecureConn
{
    public SshClient Ssh {get; set;}
    public ScpClient Scp {get; set;}

    public SecureConn(string host, string usr, string pwd)
    {
        this.Ssh = new SshClient(host, usr, pwd);
        this.Scp = new ScpClient(host, usr, pwd);
    }

    ...

}

当我尝试使用 SSH 运行 命令时 - 一切正常。但是,当我尝试使用 this.Scp.Upload()(注意构造函数中的相同凭据)将文件从网络共享上传到 Linux 服务器时,我得到 System.IO.Exception 返回 "Incorrect username or password"。出现此错误的原因可能是什么?

我需要安装任何软件才能使 SCP 在 Windows 上正常工作吗?还是以某种方式生成此消息的网络共享源?也许 Linux 服务器需要为 SCP 设置不同的密码?

我检查了 WinSCP,我可以完美地连接它并复制文件。

注意:以上只是代码示例,并非实际代码,但工作流程基本相同。我确信是 Renci 的 ScpClient.Upload 方法引发了错误,所以我在代码之外查找错误。

显然原因不在 SSH.net 库中,而是在用于登录网络共享的凭据中。对于遇到相同问题的任何人,通过 Windows(在登录提示中选中 "Remember my username and password")将凭据存储到网络共享可解决此问题。一次性访问不会。可能映射驱动器也可以,但我还没有检查过。