java + sftp

Discussion in 'Java' started by Bumsys@gmail.com, Sep 2, 2008.

  1. Guest

    I execute the program:

    public class SshExample {

    /**
    * @param args
    */

    public static void main(String[] args) {
    // TODO Auto-generated method stub
    SshClient ssh = new SshClient();

    try {
    String hostname = "localhost";
    System.out.print("Host to connect: " + hostname);
    ssh.connect(hostname);
    // ssh.connect("localhost", new
    ConsoleKnownHostsKeyVerification());

    PasswordAuthenticationClient pwd = new
    PasswordAuthenticationClient();

    String username = "anabolik";
    System.out.print("Username: " + username);
    pwd.setUsername(username);

    String password = "111";
    System.out.print("Password: " + password);
    pwd.setPassword(password);

    int result = ssh.authenticate(pwd);

    if(result==AuthenticationProtocolState.FAILED)
    System.out.println("The authentication failed");

    if(result==AuthenticationProtocolState.PARTIAL)
    System.out.println("The authentication succeeded but
    another"
    + "authentication is required");

    if(result==AuthenticationProtocolState.COMPLETE)
    System.out.println("The authentication is complete");




    SftpClient sftp = ssh.openSftpClient();

    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }

    }

    When the execute the line SftpClient sftp = ssh.openSftpClient(); I
    have error:

    SEVERE: The Transport Protocol thread failed
    java.lang.NegativeArraySizeException
    at com.sshtools.j2ssh.io.ByteArrayReader.readString(Unknown Source)
    at
    com.sshtools.j2ssh.connection.SshMsgChannelOpenFailure.constructMessage(Unknown
    Source)
    at com.sshtools.j2ssh.transport.SshMessage.fromByteArray(Unknown
    Source)
    at com.sshtools.j2ssh.transport.SshMessageStore.createMessage(Unknown
    Source)
    at
    com.sshtools.j2ssh.transport.TransportProtocolCommon.processMessages(Unknown
    Source)
    at
    com.sshtools.j2ssh.transport.TransportProtocolCommon.startBinaryPacketProtocol(Unknown
    Source)
    at com.sshtools.j2ssh.transport.TransportProtocolCommon.run(Unknown
    Source)
    at java.lang.Thread.run(Thread.java:619)
    java.io.IOException: The message store has reached EOF
    at
    com.sshtools.j2ssh.connection.ConnectionProtocol.openChannel(Unknown
    Source)
    at com.sshtools.j2ssh.SshClient.openChannel(Unknown Source)
    at com.sshtools.j2ssh.SshClient.openSftpChannel(Unknown Source)
    at com.sshtools.j2ssh.SftpClient.<init>(Unknown Source)
    at com.sshtools.j2ssh.SshClient.openSftpClient(Unknown Source)
    at com.sshtools.j2ssh.SshClient.openSftpClient(Unknown Source)
    at research.SshExample.main(SshExample.java:71)

    What can do?
    , Sep 2, 2008
    #1
    1. Advertising

  2. First of all, is the authentication succeeding? What is this block
    printing out?

    if(result==AuthenticationProtocolState.FAILED)
    System.out.println("The authentication failed");

    if(result==AuthenticationProtocolState.PARTIAL)
    System.out.println("The authentication succeeded but
    another"
    + "authentication is required");

    if(result==AuthenticationProtocolState.COMPLETE)
    System.out.println("The authentication is complete");



    --
    Michael
    http://javaconfessions.blogspot.com
    dontlikenicknames, Sep 2, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Luke

    java and ssh/sftp

    Luke, Nov 12, 2006, in forum: Java
    Replies:
    3
    Views:
    1,047
    Daniel Pitts
    Nov 13, 2006
  2. sftp + java

    , Feb 22, 2008, in forum: Java
    Replies:
    1
    Views:
    597
    GArlington
    Feb 22, 2008
  3. Replies:
    6
    Views:
    35,596
    RichTheCoder
    Aug 16, 2011
  4. MaggotChild

    Net::SFTP Fails, sftp OK

    MaggotChild, Oct 28, 2009, in forum: Perl Misc
    Replies:
    2
    Views:
    967
    C.DeRykus
    Oct 29, 2009
  5. Kevin13
    Replies:
    3
    Views:
    922
    Kevin13
    Dec 1, 2009
Loading...

Share This Page