This project is read-only.

Server SFTP version 2 is not supported

Apr 4, 2012 at 2:11 PM

I'was previously using Sharp.SSH to transfer files back and forth different servers using SFTP and had wierd behavior from time to time.

I am currently trying to switch to SSH.Net and as It seems it is more natural .Net API. So the port in my code was very easy to do but it introduced a new problem. One of the pears I was formerly connecting with Sharp.SSH stopped working Exception messageServer SFTP version 2 is not supported.

I am desperate to use this library and I know that this probably is a feature request :-) but Is there any one that can point me in the correct direction to support it?

Apr 4, 2012 at 2:40 PM



The reason you get this message is since when I was implementing SFTP protocol I was using version 3 and this is the only version currently supported.

However here are the changes from protocol 2 to 3:

o  The SSH_FXP_READLINK and SSH_FXP_SYMLINK messages were added.


   o  The SSH_FXP_STATUS message was changed to include fields `error
      message' and `language tag'.

So you can basically make a change to work with 2.0 version too.
You will need not to use link operations, it seems.
And make some modification to the SSH_FXP_STATUS message so in case of version 2.0 it will simply ignore those new 2 fields that were added.

Unfortunately I don't have access to SFTP version 2.0 which is the main reason I didn't implement it.
If you make a changes that it will work with version 2 and 3 and want me to include it in the source, feel free to let me know.

Hope it helps.


Apr 4, 2012 at 7:00 PM

Hi Oleg,

thanks for your reply. Since I am not an expert with socet/ssh programing I just poked around the source code.

I don't quite get where the changes should take place. Is it only inside the connect method of the Renci.SshNet.Session class? For example who uses the RequestStat method of the SftpSession (SSH_FXP_STAT)?

I will try to debug with the server letting the commication flow (without trowing the unsupported exception for version 2) and tell you what I found.

if (!(version.Equals("2.0") || version.Equals("1.99")))
                        throw new SshConnectionException(string.Format(CultureInfo.CurrentCulture, "Server version '{0}' is not supported.", version), DisconnectReason.ProtocolVersionNotSupported);



Apr 4, 2012 at 7:14 PM



In the file SftpSession.cs line 213, replace :


                        if (versionResponse.Version == 3)


with :

                        if (versionResponse.Version <= 3)

I think it should do.


Let me know if it works so I could do it as permanent change.




Apr 6, 2012 at 12:51 PM
Edited Apr 6, 2012 at 12:52 PM

Hi oleg thanks for the help.

I am still trying to get permission from the 3rd party sftp server to debug this from my work pc (IP restrictions). So this may take some more time. The system I am supporting is a middleware between a TELCO and bank institutions. It has other types of communications too but the most common type is sftp. The reson I am slow on responses is that banks can get a little crazy with security. When I manage to debug I'll post my progress.

By the way I run into the buffer size thing too but in a different Institution (sftp server) than the previous error. I' try to set the buffer to 16K and see what happens. The thing in my case is I got to support variety :-)