You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A third party was using FTP and is switching to SFTP.
I can connect to their new server using plain sftp command-line (on Ubuntu) but cannot connect to it using sshj. All I'm getting is a "Broken transport; encountered EOF" error.
Here is a minimal code exhibiting the issue. Note that I tried disabling server validation to rule out security issues, to no avail:
import java.io.IOException;
import java.security.PublicKey;
import java.util.List;
import net.schmizz.sshj.SSHClient;
import net.schmizz.sshj.sftp.SFTPClient;
import net.schmizz.sshj.sftp.RemoteResourceInfo;
import net.schmizz.sshj.transport.verification.HostKeyVerifier;
public class SFTPExample {
public static void main(String[] args) {
if (args.length < 4) {
System.err.println("Usage: SFTPExample host login password remoteDir");
System.exit(-1);
}
String host = args[0];
String username = args[1];
String password = args[2];
String remoteDir = args[3];
SSHClient sshClient = new SSHClient();
try {
// Disable host key verification
sshClient.addHostKeyVerifier(new HostKeyVerifier() {
public boolean verify(String hostname, int port, PublicKey publicKey) {
return true;
}
public List<String> findExistingAlgorithms(String hostname, int port) {
return null;
}
});
// Connect to the remote SFTP server
sshClient.connect(host);
sshClient.authPassword(username, password);
// Open an SFTP session
SFTPClient sftpClient = sshClient.newSFTPClient();
// List files in the remote directory
List<RemoteResourceInfo> fileList = sftpClient.ls(remoteDir);
// Print the list of files
System.out.println("Listing files in: " + remoteDir);
for (RemoteResourceInfo file : fileList) {
System.out.println(file.getName());
}
// Close the SFTP client
sftpClient.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
// Close the SSH client
if (sshClient.isConnected()) {
sshClient.disconnect();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
The log is:
[main] INFO net.schmizz.sshj.transport.random.JCERandom - Creating new SecureRandom.
[main] INFO net.schmizz.sshj.transport.TransportImpl - Client identity string: SSH-2.0-SSHJ_0.39.0
[main] INFO net.schmizz.sshj.transport.TransportImpl - Server identity string: SSH-2.0-mod_sftp
[sshj-Reader-/54.185.84.253:22-1727803034330] ERROR net.schmizz.sshj.transport.TransportImpl - Dying because - Broken transport; encountered EOF
net.schmizz.sshj.transport.TransportException: Broken transport; encountered EOF
at net.schmizz.sshj.transport.Reader.run(Reader.java:58)
[sshj-Reader-/54.185.84.253:22-1727803034330] INFO net.schmizz.sshj.transport.TransportImpl - Disconnected - UNKNOWN
[main] ERROR net.schmizz.concurrent.Promise - <<service accept>> woke to: net.schmizz.sshj.transport.TransportException: Broken transport; encountered EOF
net.schmizz.sshj.transport.TransportException: Broken transport; encountered EOF
at net.schmizz.sshj.transport.Reader.run(Reader.java:58)
When increasing the trace level, here is the part where it fails:
Hi,
A third party was using FTP and is switching to SFTP.
I can connect to their new server using plain sftp command-line (on Ubuntu) but cannot connect to it using sshj. All I'm getting is a "Broken transport; encountered EOF" error.
Here is a minimal code exhibiting the issue. Note that I tried disabling server validation to rule out security issues, to no avail:
The log is:
When increasing the trace level, here is the part where it fails:
Note: I'm using sshj-0.39.0, bcprov-jdk18on-1.78.1 and eddsa-0.3.0.jar
Any idea what could cause the issue and how to solve it ?
Am I doing something wrong :-) ?
KR, Vincent
The text was updated successfully, but these errors were encountered: