Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

java + sftp

54 views
Skip to first unread message

Bum...@gmail.com

unread,
Sep 2, 2008, 2:49:21 AM9/2/08
to
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?

dontlikenicknames

unread,
Sep 2, 2008, 9:54:59 AM9/2/08
to
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

0 new messages