0 votes
by (120 points)

Hello

Question: How Sftp library knows what Sftp.ServerType it connects to?

I am maintaining legacy handheld C# application that downloads text and binary files from sftp server.
For last couple of years sftp server was SunSSH1.1.9 installed on Sun Solaris 10. This year server was migrated to OpenSSH_7.7 on Solaris 11.
Back then Sftp.ServerType was receiving value 'Unknown', now it is 'Unix'.
Unix server type causing end line transformation, which in case of binary files, corrupts them.
https://www.rebex.net/doc/api/Rebex.Net.Sftp.ServerType.html

Application has SftpTransferType.Ascii setup in all methods. I suspect it remains from times when there was no binary files downloads.

Due to licencing I cannot modify production built of application.
I am looking for walkaround on server side. How to force server to present itself as 'Unknown' not 'Unix'.
After all, SunSSH1.1.9Solaris10 is as much Unix as OpenSSH7.7 on Solaris 11 is.

Applies to: Rebex SFTP

1 Answer

0 votes
by (144k points)
edited by

Hello,

You can simply set the ServerType property to SftpServerType.Unknown once connected and authenticated, restoring the previous behavior:

var client = new Sftp();
client.Connect(serverName, port);
client.Login(userName, password);
client.ServerType = SftpServerType.Unknown;

Be default, ServerType is choosen based either on "newline" extension (in case of SFTP v4) or on the server identification string. Apparently, SunSSH is missing from that list.

...