J2SSH & TransportProtocolException

J2SSH & TransportProtocolException - Java - Programmation

Marsh Posté le 21-08-2006 à 18:55:07    

Bonjour,
 
J'ai un serveur sur lequel le code suivant fonctionne et 2 autres pour lesquels j'ai une TransportProtocolException    
 
Code :
 
/*
 * Sshtools - Java SSH2 API
 *
 * Copyright (C) 2002 Lee David Painter.
 *
 * Written by: 2002 Lee David Painter <lee@sshtools.com>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public License
 * as published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
import java.io.BufferedReader;
import java.io.InputStreamReader;
import com.sshtools.j2ssh.SshClient;
import com.sshtools.j2ssh.authentication.AuthenticationProtocolState;
import com.sshtools.j2ssh.authentication.PasswordAuthenticationClient;
import com.sshtools.j2ssh.io.UnsignedInteger32;
import com.sshtools.j2ssh.session.SessionChannelClient;
import com.sshtools.j2ssh.sftp.FileAttributes;
import com.sshtools.j2ssh.sftp.SftpFile;
import com.sshtools.j2ssh.sftp.SftpFileOutputStream;
import com.sshtools.j2ssh.transport.IgnoreHostKeyVerification;
import com.sshtools.j2ssh.SftpClient;
import java.io.*;
import com.sshtools.j2ssh.configuration.ConfigurationLoader;
/*import java.util.logging.FileHandler;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;*/
/**
 * Demonstrates a simple password connection to an SSH server.
 *
 * @author <A HREF="mailto:lee@sshtools.com">Lee David Painter</A>
 * @version $Id: SftpConnect.java,v 1.8 2003/07/16 10:42:08 t_magicthize Exp $
 *
 * @created 20 December 2002
 */
public class SftpConnect {
  /**
   * The main program for the PasswordConnect class
   *
   * @param args The command line arguments
   */
  public static void main(String args[]) {
    try {
      ConfigurationLoader.initialize(false);
      String hostname = "xxx.xxx.xxx.xxx"; //pour raisons de sécurité ...
      SshClient ssh = new SshClient();
 
      // Connect to the host
      //HostKeyVerification myVerif = new HostKeyVerification();
      IgnoreHostKeyVerification verif = new IgnoreHostKeyVerification();
      ssh.connect(hostname,verif);
 
      // Create a password authentication instance
      PasswordAuthenticationClient pwd = new PasswordAuthenticationClient();
 
      String username = "xxxxxxxx"; //pour raisons de sécurité ...
      pwd.setUsername(username);
 
      String password = "xxxxxxxxx"; //pour raisons de sécurité ...
      pwd.setPassword(password);
      // Try the authentication
      int result = ssh.authenticate(pwd);
 
      // Evaluate the result
      if (result == AuthenticationProtocolState.COMPLETE) {
        // The connection is authenticated we can now do some real work!
        SftpClient sftp = ssh.openSftpClient();
        // Make a directory
        try {
          sftp.mkdir("j2ssh" );
        }
        catch (IOException ex) {
            ex.printStackTrace();
        }
        sftp.quit();
        ssh.disconnect();
      }
    }
    catch (Exception e) {
      e.printStackTrace();
    }
    finally {
      System.exit(0);
    }
  }
}
 
 
 
 
 
Exception :
 
2006/08/21 18:44:41:618 CEST [INFO] TransportProtocolCommon - -Starting key exchange
2006/08/21 18:44:41:618 CEST [DEBUG] TransportProtocolCommon - -Determine Algorithm
2006/08/21 18:44:41:618 CEST [DEBUG] TransportProtocolCommon - -Client Algorithms: [diffie-hellman-group1-sha1]
2006/08/21 18:44:41:618 CEST [DEBUG] TransportProtocolCommon - -Server Algorithms: [diffie-hellman-group1-sha1]
2006/08/21 18:44:41:618 CEST [DEBUG] TransportProtocolCommon - -Returning diffie-hellman-group1-sha1
2006/08/21 18:44:41:618 CEST [DEBUG] TransportProtocolCommon - -Key exchange algorithm: diffie-hellman-group1-sha1
2006/08/21 18:44:41:618 CEST [INFO] DhGroup1Sha1 - -Starting client side key exchange.
2006/08/21 18:44:41:688 CEST [INFO] TransportProtocolCommon - -Sending SSH_MSG_KEXDH_INIT
2006/08/21 18:44:41:758 CEST [DEBUG] TransportProtocolCommon - -Processing SSH_MSG_KEXDH_REPLY
2006/08/21 18:44:41:828 CEST [DEBUG] TransportProtocolCommon - -Determine Algorithm
2006/08/21 18:44:41:828 CEST [DEBUG] TransportProtocolCommon - -Client Algorithms: [ssh-dss, ssh-rsa]
2006/08/21 18:44:41:828 CEST [DEBUG] TransportProtocolCommon - -Server Algorithms: [ssh-rsa, ssh-dss]
2006/08/21 18:44:41:828 CEST [DEBUG] TransportProtocolCommon - -Returning ssh-dss
2006/08/21 18:44:41:828 CEST [DEBUG] SshDssPublicKey - -Header is ssh-dss
2006/08/21 18:44:41:828 CEST [DEBUG] SshDssPublicKey - -Verifying host key signature
2006/08/21 18:44:41:828 CEST [DEBUG] SshDssPublicKey - -Signature length is 40
2006/08/21 18:44:41:828 CEST [DEBUG] SshDssPublicKey - -SSH: 88 ad 48 1d 9a db 48 4c d5 b 8f 95 4d e4 3b 9 f8 45 83 c1 8 d2 64 68 e4 10 d5 c9 e8 1e 1 ff d a8 aa a3 95 17 be 21  
2006/08/21 18:44:41:828 CEST [DEBUG] SshDssPublicKey - -Encoded: 30 2d 2 15 0 88 ad 48 1d 9a db 48 4c d5 b 8f 95 4d e4 3b 9 f8 45 83 c1 2 14 8 d2 64 68 e4 10 d5 c9 e8 1e 1 ff d a8 aa a3 95 17 be 21  
2006/08/21 18:44:41:868 CEST [INFO] TransportProtocolCommon - -The host key signature is invalid
2006/08/21 18:44:41:868 CEST [INFO] TransportProtocolCommon - -Sending SSH_MSG_DISCONNECT
2006/08/21 18:44:41:868 CEST [INFO] TransportProtocolCommon - -Sending SSH_MSG_NEWKEYS
2006/08/21 18:44:41:868 CEST [ERROR] TransportProtocolCommon - -The Transport Protocol thread failed <com.sshtools.j2ssh.transport.TransportProtocolException: IO Error on socket: Socket closed>com.sshtools.j2ssh.transport.TransportProtocolException: IO Error on socket: Socket closed
 at com.sshtools.j2ssh.transport.TransportProtocolOutputStream.sendMessage(Unknown Source)
 at com.sshtools.j2ssh.transport.TransportProtocolCommon.sendMessage(Unknown Source)
 at com.sshtools.j2ssh.transport.TransportProtocolCommon.sendNewKeys(Unknown Source)
 at com.sshtools.j2ssh.transport.TransportProtocolCommon.beginKeyExchange(Unknown Source)
 at com.sshtools.j2ssh.transport.TransportProtocolCommon.onMsgKexInit(Unknown Source)
 at com.sshtools.j2ssh.transport.TransportProtocolCommon.startBinaryPacketProtocol(Unknown Source)
 at com.sshtools.j2ssh.transport.TransportProtocolCommon.run(Unknown Source)
 
 
Merci beaucoup pour votre aide.
 
Christophe

Reply

Marsh Posté le 21-08-2006 à 18:55:07   

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed