WinSCP .NET 程序集模拟问题:存根收到错误数据

WinSCP .NET Assembly impersonation issue: The stub received bad data

我有一个使用 WinSCP 程序集版本 5.19.5 的 .NET 控制台应用程序。该应用程序正在模拟以访问 NAS 上的文件,因此我为 Session 对象设置了 ExecutableProcessUserNameExecutableProcessPassword

Dim sessionOptions As New SessionOptions
With sessionOptions
    .Protocol = Protocol.Sftp
    .HostName = _SFTPServer
    .UserName = _SFTPLoginID
    .Password = _SFTPLoginPwd
    .PortNumber = _SFTPPort
End With

sessionOptions.SshHostKeyFingerprint =
    session.ScanFingerprint(sessionOptions, "SHA-256")

Using session As New Session
    session.ExecutableProcessUserName = _ServiceAccountUsername
    session.ExecutableProcessPassword =
        ConvertToSecureString(_ServiceAccountPassword)
    session.Open(sessionOptions)

它在 session.Open 失败并出现错误:

The stub received bad data Any ideas? Thanks

看来您需要指定域:
Stub received bad data?

session.ExecutableProcessUserName = "user@domain";

旁注:将 SessionOptions.SshHostKeyFingerprint 设置为 session.ScanFingerprint 返回的值只是 SshHostKeyPolicy.GiveUpSecurityAndAcceptAny.[=15= 的无效等价物]