Bug 2099

Summary: SshClient.connect() failure on port 22
Product: Portable OpenSSH Reporter: Mahesh <uma_537>
Component: sshAssignee: Assigned to nobody <unassigned-bugs>
Status: CLOSED INVALID    
Severity: critical CC: djm
Priority: P5    
Version: -current   
Hardware: SPARC   
OS: SunOS   

Description Mahesh 2013-05-08 21:01:45 AEST
We are facing SFTP connection issue with the metod SshClient.connect(IP,22) on port 22. This is happening only on few machines, but SFTP through putty will establish connection to the server successfully. We are using a simple stand alone program to connect using sftp protocol. 

SSH Version:
bash-3.2$ ssh -V
Sun_SSH_1.1.4, SSH protocols 1.5/2.0, OpenSSL 0x0090704f

Java Version:
1.6.0_30

Sample Program:

import com.sshtools.j2ssh.SftpClient;
import com.sshtools.j2ssh.SshClient;
import com.sshtools.j2ssh.authentication.PasswordAuthenticationClient;
import com.sshtools.j2ssh.configuration.ConfigurationLoader;
import java.io.PrintStream;

public class fileTransfer
{
  public static boolean connectToServer(String serverIp, int serverPort, String userId, String password)
  {
    SshClient sfc = null;
    try {
      System.out.println("inside Try of as its SFTP");
      ConfigurationLoader.initialize(false);
      System.out.println("ConfigurationLoader");

      sfc = new SshClient();
      sfc.connect(serverIp, serverPort);
      System.out.println("sfc.connect");

      PasswordAuthenticationClient pwd = new PasswordAuthenticationClient();

      pwd.setUsername(userId);

      pwd.setPassword(password);

      int checkAuth = sfc.authenticate(pwd);
      System.out.println("checkAuth " + checkAuth);

      if (checkAuth == 4) {
        System.out.println("AuthenticationProtocolState.COMPLETE");

        SftpClient sftp = sfc.openSftpClient();
        sftp.quit();
        sfc.disconnect();
      }
      else
      {
        throw new Exception("Invalid User Name or Password for user");
      }
    }
    catch (Exception e)
    {
		e.printStackTrace();
      System.out.println("Error While SFTP ");
      sfc.disconnect();
      e.getStackTrace();
      return false;
    }
    return true;
  }

  public static void main(String[] args)
  {
    try
    {
      System.out.println(connectToServer(args[0], Integer.parseInt(args[1]), args[2], args[3]));
    }
    catch (Exception ex) {
      ex.printStackTrace();
    }
  }
}

Error:
com.sshtools.j2ssh.transport.TransportProtocolCommon run
SEVERE: The Transport Protocol thread failed
java.lang.ArrayIndexOutOfBoundsException
        at java.lang.System.arraycopy(Native Method)
        at com.sshtools.j2ssh.transport.TransportProtocolInputStream.readBufferedData(Unknown Source)
        at com.sshtools.j2ssh.transport.TransportProtocolInputStream.readMessage(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:662)
com.sshtools.j2ssh.transport.MessageStoreEOFException: The message store has reached EOF
        at com.sshtools.j2ssh.transport.SshMessageStore.getMessage(Unknown Source)
        at com.sshtools.j2ssh.transport.SshMessageStore.getMessage(Unknown Source)
        at com.sshtools.j2ssh.transport.SshMessageStore.getMessage(Unknown Source)
        at com.sshtools.j2ssh.transport.TransportProtocolClient.requestService(Unknown Source)
        at com.sshtools.j2ssh.SshClient.connect(Unknown Source)
        at com.sshtools.j2ssh.SshClient.connect(Unknown Source)
        at com.sshtools.j2ssh.SshClient.connect(Unknown Source)
        at fileTransfer.connectToServer(fileTransfer.java:18)
        at fileTransfer.main(fileTransfer.java:57)
Error While SFTP
false


Please help us in resolving this issue.
Comment 1 Damien Miller 2013-05-08 22:51:29 AEST
(In reply to comment #0)
> SSH Version:
> bash-3.2$ ssh -V
> Sun_SSH_1.1.4, SSH protocols 1.5/2.0, OpenSSL 0x0090704f
  ^^^^^^^^^^^^^^
Not OpenSSH

> Java Version:
> 1.6.0_30
> 
> com.sshtools.j2ssh.transport.TransportProtocolCommon run
  ^^^^^^^^^^^^^^^^^^
Also not OpenSSH

Sorry, but we can't help you figure out code we didn't write.
Comment 2 Damien Miller 2016-08-02 10:41:04 AEST
Close all resolved bugs after 7.3p1 release