Question

So, I used the example on http://www.jcraft.com/jsch/examples/Sftp.java and I was trying to connect to ftp.secureftp-test.com.

That destination is a valid testing SFTP server (as mentioned in secureftp-test dot com/). I confirmed it by connecting to the server through nautilus. I also made sure that the password on my program was correct as well.

But, when I run the program and it hits session.connect(), it just says "INFO: Connection established" then it becomes quiet for a minute then it return: "com.jcraft.jsch.JSchException: connection is closed by foreign host"

I am pretty sure that it got stuck in the while loop of the library but I do not know why. I tried it against my local ftp server and it also had the same problem.

During the quiet moment, I can type. But pressing enter does not send anything to the server.

Has anyone heard or seen the same problem?

Was it helpful?

Solution

Okay, it seems that secureftp-test.com is NOT an sftp server. That is ftps server.

What I did instead was creating my own sftp: http://wiki.vpslink.com/Configuring_vsftpd_for_secure_connections_(TLS/SSL/SFTP)

Then run the example code but making sure that I have these lines before doing session.connect:

String knownHostsFilename = "/home/yourname/.ssh/known_hosts";
jsch.setKnownHosts(knownHostsFilename);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top