I am evaluating the trial version of edtFTPj/PRO 1.2.5 and have run into the situation where SSHFTPCLient connect() hangs on two machines but works on a third. I am using password authentication:
if (args.length < 4 || args.length > 5) {
throw new Exception("Usage: SFTPTest <host> <port> <login> <password> [known_hosts file]");
}
String host = args[0];
int port = Integer.parseInt(args[1]);
String login = args[2];
String password = args[3];
log.info("Create SFTP client");
SSHFTPClient ftp = new SSHFTPClient();
ftp.setRemoteHost(host);
ftp.setRemotePort(port);
ftp.setAuthentication(login, password);
if (args.length < 5) {
ftp.getValidator().setHostValidationEnabled(false);
} else {
String knownHosts = args[4];
ftp.getValidator().loadKnownHosts(knownHosts);
}
log.info("Connect");
ftp.setTimeout(5000);
ftp.connect();
log.info("Files:");
String[] files = ftp.dir(".");
for (int i = 0; i < files.length; i++) {
log.info(" " + files[i]);
}
log.info("Done");
ftp.quit();
In both failure cases the debug log ends with:
07 Mar 2006 13:02:09 Transport protocol 1 DEBUG com.enterprisedt.net.j2ssh.transport.TransportProtocolCommon Starting key exchange
07 Mar 2006 13:02:09 Transport protocol 1 DEBUG com.enterprisedt.net.j2ssh.transport.TransportProtocolCommon Returning diffie-hellman-group1-sha1
07 Mar 2006 13:02:09 Transport protocol 1 DEBUG com.enterprisedt.net.j2ssh.transport.kex.DhGroup1Sha1 Starting client side key exchange.
07 Mar 2006 13:02:09 Transport protocol 1 DEBUG com.enterprisedt.net.j2ssh.transport.TransportProtocolCommon Verifying host ftp1.uwp.washington.edu,140.142.233.36
07 Mar 2006 13:02:09 Transport protocol 1 DEBUG com.enterprisedt.net.j2ssh.transport.TransportProtocolCommon Preferred algorithm null
07 Mar 2006 13:02:09 Transport protocol 1 DEBUG com.enterprisedt.net.j2ssh.transport.TransportProtocolCommon Returning ssh-dss
07 Mar 2006 13:02:09 Transport protocol 1 DEBUG com.enterprisedt.net.j2ssh.transport.TransportProtocolCommon Selected algorithm ssh-dss
07 Mar 2006 13:02:09 Transport protocol 1 DEBUG com.enterprisedt.net.j2ssh.transport.publickey.dsa.SshDssPublicKey Header is ssh-dss
07 Mar 2006 13:02:09 Transport protocol 1 DEBUG com.enterprisedt.net.j2ssh.transport.TransportProtocolCommon The host key signature is valid
07 Mar 2006 13:02:09 Transport protocol 1 DEBUG com.enterprisedt.net.j2ssh.transport.TransportProtocolCommon Completing key exchange
07 Mar 2006 13:02:09 Transport protocol 1 DEBUG com.enterprisedt.net.j2ssh.transport.TransportProtocolCommon Making keys from key exchange output
07 Mar 2006 13:02:09 Transport protocol 1 DEBUG com.enterprisedt.net.j2ssh.transport.TransportProtocolCommon Creating algorithm objects
07 Mar 2006 13:02:09 Transport protocol 1 DEBUG com.enterprisedt.net.j2ssh.transport.TransportProtocolCommon Returning 3des-cbc
07 Mar 2006 13:02:09 Transport protocol 1 DEBUG com.enterprisedt.net.j2ssh.transport.cipher.SshCipherFactory Creating new 3des-cbc cipher instance
I also noticed a CPU profile showed a significant amount of time in:
25.0% 0 + 8 java.net.SocketInputStream.socketRead0
18.8% 6 + 0 com.enterprisedt.net.j2ssh.transport.TransportProtocolAlgorithmSync.lock
12.5% 3 + 1 java.lang.Object.wait
The successful case gets past this point, and interestingly is creating a blowfish-cbc cipher instance instead.
Anyone have an idea about what could be causing connect() to hang? Thanks in advance ...