Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
13.2k views
in Java FTP by (160 points)
Hello guys, I have a problem, (and have googled a lot,) can some one help me?

I am behind a proxy(squid proxy) that needs authentication, and want to make an FTP connection to an FTP server outside my network, how to do it using edtFtp;

for example assume

proxy server ip = 123.456.789
proxy username = myusername
proxy password = mypassword

ftp server ip = 987.654.321
ftp uer name = ftpusername
ftp password = ftppassword

Many Thanks in advance

8 Answers

0 votes
by (162k points)
One approach that might work is described here:

http://www.enterprisedt.com/products/ed ... rvers.html

If SOCKS is enabled, you can do this:

http://www.enterprisedt.com/products/ed ... proxy.html
0 votes
by (160 points)
Ya, have seen that, but there is no facility to provide the proxy user name and password, my proxy needs authentication and yes, SOCKS is not enabled.
0 votes
by (162k points)
Can you get Filezilla working? It gives you a number of options to do with using a proxy. If that works, post the Filezilla log and we should be able to tell you how to do it. Generally involves using the ACCT command.
0 votes
by (180 points)
Status: Using proxy proxyIP
Status: Connecting to proxyIP:21...
Status: Connection established, waiting for welcome message...
Response: 220--------------= TPN/BTINS FTP proxy service =------------
Response: 220---- --
Response: 220---- --
Response: 220---- --
Response: 220---- --
Response: 220---- AUTHORIZED USERS ONLY! --
Response: 220---- ALL TRANSFERS PERFORMED WITH THIS SERVICE ARE LOGGED --
Response: 220---- --
Response: 220---- --
Response: 220---- At the User prompt, enter your FTP site username and the site --
Response: 220---- you are connecting to, followed by your domain login ID. --
Response: 220---- --
Response: 220---- EXAMPLE: anonymous@microsoft.com AMSmithJ --
Response: 220---- --
Response: 220---- At the Password prompt, enter your FTP site password. --
Response: 220---- --
Response: 220---- At the Enter Password prompt, enter your domain password. --
Response: 220---- --
Response: 220 -----------------------------------------------------------------------
Command: USER remoteusername@remoteHost proxyUserName
Response: 331 Enter password.
Command: PASS ********
Response: 332 Enter proxy password.
Command: ACCT *********
Response: 230-Your bandwidth usage is restricted
Response: 230-User username has group access to: apache
Response: 230-This server supports FXP transfers
Response: 230 OK. Current restricted directory is /
Status: Connected
Status: Retrieving directory listing...
Command: PWD
Response: 257 "/" is your current location
Command: TYPE I
Response: 200 Command okay.
Command: PASV
Response: 227 Entering Passive Mode (00,11,255,11,251,170)
Command: LIST -a
Response: 150 File status okay; about to open data connection.
Response: 226 Transfer complete, closing data connection.
Status: Directory listing successful


I have set the settings in Filezilla for FTP proxy with custom settings as
USER %u@%h %s
PASS %p
ACCT %w

where %h is remotehost, %u is remoteUserName, %s is proxyusername, %p is remoteHostPassword, %w is proxyPassword.

And here is the code I'm using to ftp to the remoteHost:
FTPClient ftpClient = new FTPClient("remoteHostIP", 21);
ftpClient.setConnectMode(FTPConnectMode.PASV);
FTPClient.initSOCKS("1080", "proxyserverIP");
FTPClient.initSOCKSAuthentication("proxyUserName" , "proxyPassword");
ftpClient.login("remoteUserName", "remotePassword");
this code is giving me : java.net.SocketException: Reply from SOCKS server has bad version
at java.net.SocksSocketImpl.connectV4(SocksSocketImpl.java:300)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:371)
at java.net.Socket.connect(Socket.java:478)
at java.net.Socket.connect(Socket.java:428)
at java.net.Socket.<init>(Socket.java:335)
at java.net.Socket.<init>(Socket.java:150)
at com.enterprisedt.net.ftp.FTPControlSocket.<init>(FTPControlSocket.java:139)
at com.enterprisedt.net.ftp.FTPClient.<init>(FTPClient.java:150)

Can you help me resolve this? Thanks In Advance.
0 votes
by (162k points)
The key is the settings you've worked out:

USER %u@%h %s
PASS %p
ACCT %w

So you need to supply these settings. With FTPClient you can do this via

login(String user, String password, String accountInfo)

e.g.

login("user@host proxyuser", "pwd", "proxypwd");
0 votes
by (180 points)
It worked great!! Thank you.
0 votes
by (180 points)
Hi guys,

I have the same problem but Filezilla uses the following settings:

USER %s
PASS %w
USER %u@%h
PASS %p
ACCT %a

How can I resolve this using FTPClient?

Kind regards

Iggy
0 votes
by (162k points)
That would be similar, but you need 2 commands, something like:

login("user", "pwd");
login("user@host", "proxypassword", "whateverthisis");

You'll have to experiment a bit and look at the log file.

Categories

...