0 votes
by (120 points)
edited by

I'm unable to connect to an FTP server with the following custom FTP proxy:

USER %u@%h %s

Do you support this?

Applies to: Rebex FTP/SSL

3 Answers

0 votes
by (18.0k points)

There is no pre-defined proxy type in the FtpProxyType enumeration.

However, if you need to connect through proxy using exactly the mentioned syntax

USER %username@%host %proxyUser
PASS %password
ACCT %proxyPassword

you can do it with the following code:

Ftp ftp = new Ftp();
string username = ""; 
string password = ""; 
string host = "";
string proxyUser = "bob.kent"; 
string proxyPassword = "*****"; 
string proxyHost = "";
ftp.Login(username + "@" + host + " " + proxyUser, password, proxyPassword);

Note: no setting of the ftp.Proxy property is needed in this situation.

by (120 points)

This works! The proxy credentials are the same as the windows credentials... is there any way I can pass these along so that I don't have to ask the user for the proxy credentials?

by (18.0k points)

I think it is not possible, but I'd like to consult it with my colleague tomorrow. Than I'll write you the final answer.

edited by anonymous
i have the same custom proxy settings but the code above doesn't work for me -.-

i have to set proxy settings ( proxytype = FtpUser and host ). otherwise i can't connect to the ftp server and this exception comes up: No connection could be made because the target machine actively refused it.

when connected, the code above does not work throwing the exception "ACCT proxypassword (530)".
(username, password and host were not empty).

who can help me?

- my fault... i connected to the ftp instead of proxy -.-
by (70.4k points)
Great, that you solved the issue.
having the same proxy custom settings, how to connect to a SFTP server and especially login?  the login method for sftp does not provide parameters: @username @pw, @account.

thank you in advance!
by (70.4k points)
Actually, this is not possible with SFTP, unless your proxy supports SSH. From the syntax of your proxy, it doesn't seem that the proxy supports it.

Maybe you are trying to use FTPS (which is rather called FTP/SSL) instead of SFTP?  To understand differences see http://www.rebex.net/kb/secure-ftp.

However, in that case, the proxy have to support SSL. If not, there is no need to use any secured protocol, because the password from your proxy to the remote host is sent in plaintext.
0 votes
by (147k points)

Unfortunately, Jan is right - this is not possible. Essentially, you would need a way to retrieve the current user's username and password, which is not possible for security reasons.

As far as I know, the only way to re-use Windows credentials is using NTLM or Kerberos authentication (both support single-sign-on, sometimes refered to as Windows integrated authentication) and none of them applies here (unless you switch to an HTTP CONNECT proxy).

0 votes
by (140 points)
edited by

Hello. Have the same question. How can i connect to the remote ftp server, using proxy from http://advanced.name ?

by (147k points)
They seem to offer proxies that support multiple protocols at once and recommend using SOCKS5 (see http://advanced.name/faq). To connect to a SOCKS5 proxy using Rebex FTP/SSL, use the following code:

    var ftp = new Ftp();
    ftp.Proxy.ProxyType = FtpProxyType.Socks5;
    ftp.Proxy.Host = ""; // replace with proxy address
    ftp.Proxy.Port = 1080; // replace with proxy port
    //ftp.Proxy.UserName = "user01"; // use your user name
    //ftp.Proxy.Password = "password"; // use your password

    ftp.Connect("test.rebex.cz", SslMode.Explicit); // use the desired host name and SSL mode

However, I have been unable to try this with their free proxies - most of them seem to prohibit FTP (see the note at the end of http://advanced.name/freeproxy).