Currently on our Linux server we connect to a remote SFTP server using the following command:
sftp -o IdentityFile=/path/to/file/myFile username@foo.bar.com
I just downloaded the trial version of edtFTPj/PRO to see if we could accomplish the same thing but I'm running into problems. Here's the code I'm using:
SSHFTPClient ftp = new SSHFTPClient();
ftp.setRemoteHost("foo.bar.com");
ftp.setAuthentication("/path/to/file/myFile", "username");
ftp.getValidator().loadKnownHosts("/path/to/known_hosts");
ftp.connect();
I get the following error:
com.enterprisedt.net.j2ssh.authentication.AuthenticationProtocolException: Failed to read messages
at com.enterprisedt.net.j2ssh.authentication.AuthenticationProtocolClient.A(Unknown Source)
at com.enterprisedt.net.j2ssh.authentication.AuthenticationProtocolClient.readMessage(Unknown Source)
at com.enterprisedt.net.j2ssh.authentication.PasswordAuthenticationClient.authenticate(Unknown Source)
at com.enterprisedt.net.j2ssh.authentication.AuthenticationProtocolClient.authenticate(Unknown Source)
at com.enterprisedt.net.j2ssh.SshClient.authenticate(Unknown Source)
at com.enterprisedt.net.ftp.ssh.SCPClient.connectSSH(Unknown Source)
at com.enterprisedt.net.ftp.ssh.SSHFTPClient.connect(Unknown Source)
at com.remitpro.zftp.main(zftp.java:67)
Caused by: com.enterprisedt.net.j2ssh.transport.MessageStoreEOFException: The message store has reached EOF
at com.enterprisedt.net.j2ssh.transport.SshMessageStore.getMessage(Unknown Source)
at com.enterprisedt.net.j2ssh.transport.SshMessageStore.getMessage(Unknown Source)
... 8 more
I'm obviously not setting something up correctly...any advice?