Skip to content

EOF when trying to read/write file using Tectia SSH Server #54

Closed
@incendium

Description

@incendium

We're having issues communicating with Tectia's SSH server using the latest SSHJ client (0.7.0). Here's the test code and a dump of the error log:

import java.io.InputStream;

import net.schmizz.sshj.SSHClient;
import net.schmizz.sshj.sftp.SFTPEngine;
import net.schmizz.sshj.sftp.StatefulSFTPClient;
import net.schmizz.sshj.transport.verification.PromiscuousVerifier;

import org.apache.commons.io.IOUtils;

public class SFTPTest {
  public static void main(String[] args)
      throws Exception {
    SSHClient client = new SSHClient();
    client.addHostKeyVerifier(new PromiscuousVerifier());
    client.connect("127.0.0.1", 22);
    client.authPassword("test", "test");

    StatefulSFTPClient sftp = new StatefulSFTPClient(new SFTPEngine(client).init());
    System.out.println("File Exists: " + sftp.statExistence("test.txt"));

    InputStream input = sftp.open("test.txt").getInputStream();
    IOUtils.copy(input, System.out);
    IOUtils.closeQuietly(input);

    sftp.close();
    client.close();
  }
}

stdout:

File Exists: [size=14;mode=[mask=100600];atime=1326843624,mtime=1326843624;]

stderr:

317 [main] INFO net.schmizz.sshj.common.SecurityUtils - Trying to register BouncyCastle as a JCE provider
800 [main] INFO net.schmizz.sshj.common.SecurityUtils - Registration succeeded
853 [main] INFO net.schmizz.sshj.transport.TransportImpl - Client identity string: SSH-2.0-SSHJ_0_7
856 [main] INFO net.schmizz.sshj.transport.TransportImpl - Server identity string: SSH-2.0-6.2.3.168 SSH Tectia Server
857 [main] INFO net.schmizz.sshj.transport.KeyExchanger - Sending SSH_MSG_KEXINIT
5348 [reader] INFO net.schmizz.sshj.transport.KeyExchanger - Received SSH_MSG_KEXINIT
5395 [reader] INFO net.schmizz.sshj.transport.kex.DHG14 - Sending SSH_MSG_KEXDH_INIT
5536 [reader] INFO net.schmizz.sshj.transport.KeyExchanger - Received kex followup data
5537 [reader] INFO net.schmizz.sshj.transport.kex.DHG14 - Received SSH_MSG_KEXDH_REPLY
5582 [reader] INFO net.schmizz.sshj.transport.KeyExchanger - Sending SSH_MSG_NEWKEYS
5582 [reader] INFO net.schmizz.sshj.transport.KeyExchanger - Received SSH_MSG_NEWKEYS
5586 [main] INFO net.schmizz.sshj.SSHClient - Key exchange took 4.729 seconds
5588 [reader] INFO net.schmizz.sshj.transport.TransportImpl - Received SSH_MSG_IGNORE
5707 [reader] INFO net.schmizz.sshj.transport.TransportImpl - Received SSH_MSG_IGNORE
5707 [main] INFO net.schmizz.sshj.transport.TransportImpl - Setting active service to ssh-userauth
5708 [main] INFO net.schmizz.sshj.userauth.UserAuthImpl - Trying `password` auth...
5708 [main] INFO net.schmizz.sshj.userauth.method.AuthPassword - Requesting password for [AccountResource] test@127.0.0.1
5725 [reader] INFO net.schmizz.sshj.transport.TransportImpl - Received SSH_MSG_IGNORE
5819 [reader] INFO net.schmizz.sshj.transport.TransportImpl - Received SSH_MSG_IGNORE
5819 [main] INFO net.schmizz.sshj.userauth.UserAuthImpl - `password` auth successful
5819 [main] INFO net.schmizz.sshj.transport.TransportImpl - Setting active service to ssh-connection
5835 [main] INFO net.schmizz.sshj.connection.ConnectionImpl - Attaching `session` channel (#0)
5836 [reader] INFO net.schmizz.sshj.transport.TransportImpl - Received SSH_MSG_IGNORE
5840 [reader] INFO net.schmizz.sshj.connection.channel.direct.SessionChannel - Initialized - < session channel: id=0, recipient=0, localWin=[winSize=2097152], remoteWin=[winSize=65536] >
5840 [main] INFO net.schmizz.sshj.connection.channel.direct.SessionChannel - Will request `sftp` subsystem
5840 [main] INFO net.schmizz.sshj.connection.channel.direct.SessionChannel - Sending channel request for `subsystem`
5919 [reader] INFO net.schmizz.sshj.transport.TransportImpl - Received SSH_MSG_IGNORE
5929 [reader] INFO net.schmizz.sshj.transport.TransportImpl - Received SSH_MSG_IGNORE
5929 [reader] INFO net.schmizz.sshj.transport.TransportImpl - Received SSH_MSG_IGNORE
5929 [main] INFO net.schmizz.sshj.sftp.SFTPEngine - Server version 3
5935 [reader] INFO net.schmizz.sshj.transport.TransportImpl - Received SSH_MSG_IGNORE
5935 [reader] INFO net.schmizz.sshj.transport.TransportImpl - Received SSH_MSG_IGNORE
5937 [main] INFO net.schmizz.sshj.sftp.StatefulSFTPClient - Start dir = /C:/Documents and Settings/test
5939 [reader] INFO net.schmizz.sshj.transport.TransportImpl - Received SSH_MSG_IGNORE
5941 [reader] INFO net.schmizz.sshj.transport.TransportImpl - Received SSH_MSG_IGNORE
5962 [reader] INFO net.schmizz.sshj.transport.TransportImpl - Received SSH_MSG_IGNORE
5963 [reader] INFO net.schmizz.sshj.transport.TransportImpl - Received SSH_MSG_IGNORE
5973 [reader] INFO net.schmizz.sshj.transport.TransportImpl - Received SSH_MSG_IGNORE
5973 [reader] INFO net.schmizz.sshj.connection.channel.direct.SessionChannel - Got chan request for `exit-status`
5973 [reader] INFO net.schmizz.sshj.transport.TransportImpl - Received SSH_MSG_IGNORE
5973 [reader] INFO net.schmizz.sshj.connection.channel.direct.SessionChannel - Got EOF
5973 [reader] INFO net.schmizz.sshj.transport.TransportImpl - Received SSH_MSG_IGNORE
5992 [reader] INFO net.schmizz.sshj.connection.channel.direct.SessionChannel - Got close
5992 [reader] INFO net.schmizz.sshj.connection.channel.direct.SessionChannel - Sending EOF
5993 [reader] INFO net.schmizz.sshj.connection.channel.direct.SessionChannel - Sending close
5993 [reader] INFO net.schmizz.sshj.connection.ConnectionImpl - Forgetting `session` channel (#0)
5996 [main] ERROR net.schmizz.concurrent.Promise - <<sftp / 4>> woke to: net.schmizz.sshj.sftp.SFTPException: EOF while reading packet
Exception in thread "main" net.schmizz.sshj.sftp.SFTPException: EOF while reading packet
  at net.schmizz.sshj.sftp.PacketReader.readIntoBuffer(PacketReader.java:52)
  at net.schmizz.sshj.sftp.PacketReader.getPacketLength(PacketReader.java:57)
  at net.schmizz.sshj.sftp.PacketReader.readPacket(PacketReader.java:67)
  at net.schmizz.sshj.sftp.PacketReader.run(PacketReader.java:84)

You can grab the server here - http://www.tectia.com/en/Customers/Evaluate/Client_-_Server.iw3. I have only tested the Windows server (on XP). Setup is relatively straight forward, everything is set up straight out of the box, all you need to do is create a user named test with the password test and drop a file called "test.txt" into their home directory.

Let me know if you need any more info.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions