0 votes
by (140 points)
edited by

I am using sftp to connect to a sftp directory but when passive mode is not selected in filezilla i cannot connect and the same goes for when i attempt my normal code which is as below how would one enable the code for passive mode sftp.

The error that i get is the following says username and password incorrect but i no its not as I can connect in filezilla with passive mode being active.

public void sendFileToSftp(string filename, string serverFile, string IVARef, string firstname,string lastname,string hostname, string port, string username, string password)

        // create client, connect and log in
        Sftp client = new Sftp();

        client.Login(username, password);
        client.TransferProgressChanged += new EventHandler<SftpTransferProgressChangedEventArgs>(sftp_TransferProgressChanged);
        client.CreateDirectory(IVARef + " " + firstname + "  " + lastname);
        // upload the 'test.zip' file to the current directory at the server
        client.PutFile(filename, serverFile);

    catch (Exception ex)

        string inner = string.Empty;
        if (ex.InnerException != null)
            inner = ex.InnerException.ToString();
        //     logger.Error("Error in GetNotificationById function aperturenetdal " + ex.ToString() + " " + inner);
        return "";
Applies to: Rebex SFTP

1 Answer

0 votes
by (58.9k points)


SFTP and FTP/SSL are completely different file transfer protocols. See http://www.rebex.net/kb/secure-ftp/

Also there is no active or passive mode in SFTP protocol.

You probably are referring to FTP protocol.
In that case, just change your code from:

Sftp client = new Sftp();


Ftp client = new Ftp();

In FTP client the passive mode is default, so no need to set anything more.

by (58.9k points)
So just give it a try with the Ftp component and let us know if it works.