EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Can't download file through SFTP

Posted: 08/20/2010 02:25:55
by Oleksiy Kravchuk (Basic support level)
Joined: 08/20/2010
Posts: 3

Dear all,

I'm evaluating your component. It works ok with several servers except one. Also I'm estimating component from other vendor - it works with that server successfully.
Server: ftpstream.com - you may create trial account there.
Protocol : SFTP
Port: 22
Problem: when I download a file it is created on local drive but with size 0 bytes (empty).

Example of code I'm using to download:

m_ftpClient.ASCIIMode = false;
string remoteFileFullPath = Utilities.PathCombine(remoteFile.Path, remoteFile.Name);
remoteFileFullPath = m_ftpClient.RequestAbsolutePath(remoteFileFullPath);
m_ftpClient.DownloadFile(remoteFileFullPath, localFileFullName, TSBSFTPFileTransferMode.ftmOverwrite);

NB: this code works ok on other servers.

To initialize m_ftpClient I use the following code:


m_keyStorage = new TElSSHMemoryKeyStorage();
m_ftpClient = new TElSimpleSFTPClient();
m_ftpClient.KeyStorage = m_keyStorage;
m_ftpClient.OnKeyValidate += new SBSSHCommon.TSSHKeyValidateEvent(this.SftpClient_OnKeyValidate);

m_ftpClient.Address = m_connectionSettings.ServerUrl;
m_ftpClient.AuthenticationTypes = SBSSHConstants.Unit.SSH_AUTH_TYPE_PASSWORD;

if (m_connectionSettings.Port > 0)
m_ftpClient.Port = m_connectionSettings.Port;

if (m_connectionSettings.IsAnonimous == false)
m_ftpClient.Username = m_connectionSettings.UserName;
m_ftpClient.Password = m_connectionSettings.Password;

m_ftpClient.OnError -= new SBSSHCommon.TSSHErrorEvent(ConnectionObjectOnError);
m_ftpClient.OnError += new SBSSHCommon.TSSHErrorEvent(ConnectionObjectOnError);

Connection is open:

public void Open()
if (m_ftpClient.Active)
m_state = ConnectionState.Open;
m_state = ConnectionState.Connecting;
m_state = m_ftpClient.Active ? ConnectionState.Open : ConnectionState.Closed;

If you need more details - I've attached archived Visual Studio 2008 test solution.

[ Download ]
Posted: 08/20/2010 03:20:43
by Mykola Olshevsky (Basic support level)
Joined: 07/07/2005
Posts: 442

It seems, that this server doesn't work as it should. With enabled higher protocol versions (5 anf 6), it returns 'permission denied' to read request.
To make it work, please limit SFTP client protocol version to 4 (SftpClient.Versions := [sbSFTP1, sbSFTP2, sbSFTP3, sbSFTP4];
Posted: 08/20/2010 03:36:43
by Oleksiy Kravchuk (Basic support level)
Joined: 08/20/2010
Posts: 3

Thanks, Mykolo! - your solution worked out.
Posted: 08/20/2010 04:22:22
by Oleksiy Kravchuk (Basic support level)
Joined: 08/20/2010
Posts: 3

Mykolo, how did you recognize that matter of problem?
I suppose you enable logging somehow. If it is true, how can I do this?

Posted: 08/20/2010 05:06:22
by Mykola Olshevsky (Basic support level)
Joined: 07/07/2005
Posts: 442

I just debugged through the code, which is available to EldoS developers and our customers as well :)
Actually, it is a common problem of SFTP server, which claims that they support SFTP protocol version 5 & 6, but don't do that properly.



Topic viewed 1783 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS business operates as a division of /n software, inc. For more information, please read the announcement.

Got it!