0 votes
by (170 points)
edited

We have an automated ftp transfer using Rebex SFTP. But we cannot connect to the SFTP server unless there is a connection already made at the same time by another client (FileZilla). Log information is shown below. We are using the default SSH parameters when connecting. That is, we connect like this:

Sftp conn = new Sftp();
conn.Connect("ftp.example.com", 22);
// verify fingerprint...
conn.Login("joeuser", "joeuser's password");

Any ideas?

Logs are as follows:

If FileZilla is connected when we try to connect, we get this in the log:

2012-05-16 09:25:35.610 INFO Sftp(33) Info: Connecting to ftp.example.com:22 using Sftp 2.0.4086.0.
2012-05-16 09:25:35.688 INFO Sftp(33) SSH: Negotiation started.
2012-05-16 09:25:36.078 INFO Sftp(33) SSH: Negotiation finished.
2012-05-16 09:25:36.078 INFO Sftp(33) Info: Server: SSH-2.0-9.99 sshlib: 7.0.0.0
2012-05-16 09:25:36.078 INFO Sftp(33) Info: Fingerprint: dc:08:44:26:ab:3c:a9:5e:45:24:ba:d8:7f:a4:be:6e
2012-05-16 09:25:36.078 INFO Sftp(33) Info: Cipher info: SSH 2.0, DiffieHellmanGroupExchangeSHA1, DSS, aes256-ctr/aes256-ctr, SHA1/SHA1
2012-05-16 09:25:36.702 INFO Sftp(33) Command: SSH_FXP_INIT (4)
2012-05-16 09:25:36.749 INFO Sftp(33) Response: SSH_FXP_VERSION (3, 0 extensions)
2012-05-16 09:25:36.749 INFO Sftp(33) Info: Using SFTP v3.
...

If there isn't another connection already established at the time, we timeout waiting for the welcome message, and this is what we get in the log:

2012-05-16 09:21:57.973 INFO Sftp(31) Info: Connecting to ftp.example.com:22 using Sftp 2.0.4086.0.
2012-05-16 09:22:59.235 ERROR Sftp(31) SSH: Rebex.Net.SshException: Timeout exceeded while waiting for welcome message. Make sure you are connecting to an SSH or SFTP server.
at Rebex.Net.SshSession.bOtYJuZ()
at Rebex.Net.SshSession.Negotiate())
2012-05-16 09:22:59.235 ERROR Sftp(31) Info: Rebex.Net.SshException: Timeout exceeded while waiting for welcome message. Make sure you are connecting to an SSH or SFTP server.)
at Rebex.Net.SshSession.bOtYJuZ())
at Rebex.Net.SshSession.Negotiate())
at Rebex.Net.Sftp.Connect(String serverName, Int32 serverPort, SshParameters parameters))

Applies to: Rebex SFTP

1 Answer

0 votes
by (148k points)
edited

This is strange. A possible explanation might be an Antivirus software (or something similar) that blocks communication on connection established by Rebex SFTP unless FileZilla establishes it first, but this is only a speculation at this point.

Please try running the following code in your application before calling Sftp.Connect that tries to send&receive an SSH message without using any Rebex code:

        using System;
        using System.IO;
        using System.Net.Sockets;
        ...

        // connect to the SFTP/SSH server
        TcpClient client = new TcpClient();
        client.Connect("ftp.example.com", 22);

        // initialize reader and writer
        NetworkStream stream = client.GetStream();
        StreamReader reader = new StreamReader(stream);
        StreamWriter writer = new StreamWriter(stream);
        writer.NewLine = "\r\n";

        // send client welcome message
        writer.WriteLine("SSH-2.0-TestSSH_1.0");

        // receive and display server welcome message
        string welcome = reader.ReadLine();
        Console.WriteLine(welcome);

        // close the connection
        client.Close();

Does it behave the same way as Rebex SFTP, or is there any difference?

...