简体   繁体   中英

Connect and download files from Bitvise SFTP server with SSH protocol obfuscation in C#

I have SFTP server which is able to connect via (Bitvise SSH client) with the help of Obfuscation Password. But, unable to connect the same via c# code.

Here is my code:

winSCPSrc.SessionOptions sessionOptionss = new winSCPSrc.SessionOptions();
sessionOptionss.Protocol = winSCPSrc.Protocol.Sftp;
sessionOptionss.PortNumber = Port;
sessionOptionss.HostName = Host;
sessionOptionss.UserName = Username;
if (!string.IsNullOrEmpty(Password))
{
    sessionOptionss.Password = Password;
}
//sessionOptionss.GiveUpSecurityAndAcceptAnySshHostKey = true;
sessionOptionss.SshHostKeyFingerprint = fingerPrint;

using (winSCPSrc.Session session = new winSCPSrc.Session())
{
    State.KPILog.Info(" SFTP Connection trying to Open ");
    session.AddRawConfiguration("DefaultConfiguration", "false");
    // Connect
    session.Open(sessionOptionss);
    State.KPILog.Info("SFTP Connection Open ");
    // ...
}

I'm getting "Server unexpectedly closed network connection" error while session.Open(sessionOptionss) .

Please let me know there is any other libraries available other than winscp to connect SFTP.

What I have tried:

  • Able to connect and download files via Bitvise SSH client but unable to implement it in C# code.

  • Our IT provider has given some "Obfuscation Password" for connecting via Bitvise ssh client. I have no idea how it works in C# code.

Bitvise FAQ says ( emphasis mine):

If all of your legitimate connections come from Bitvise SSH Client, you can enable SSH protocol obfuscation in the SSH Server in Advanced settings, under Bindings and UPnP. If you enable obfuscation, only Bitvise SSH Client will be able to connect , and then only if configured with the correct obfuscation keyword.

It seems that the "obfuscation" is a proprietary feature of Bitvise. So it's likely that Bitvise products support it only. Bitvise has FlowSsh library . As Bitvise client is apparently built on top of the library, you should be able to use the library from your C# code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM