The socket is EOF : J2SSH
Bonjour à tous. Je viens de découvrir une API qui me semble intéressante qui se nomme J2SSH (sshtools) que vous pouvez trouver ici : http://sourceforge.net/projects/sshtools/.
mon problème est que j'ai fait un petit programme :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| import java.io.FileInputStream;
import com.sshtools.j2ssh.SshClient;
import com.sshtools.j2ssh.authentication.AuthenticationProtocolState;
import com.sshtools.j2ssh.authentication.PasswordAuthenticationClient;
public class MainClass {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String hostname = new String("10.20.10.15");
String username = new String("admin");
String password = new String("password");
SshClient ssh = new SshClient();
try {
ssh.connect(hostname, 22);
//Authenticate
PasswordAuthenticationClient passwordAuthenticationClient = new PasswordAuthenticationClient();
passwordAuthenticationClient.setUsername(username);
passwordAuthenticationClient.setPassword(password);
int result = ssh.authenticate(passwordAuthenticationClient);
ssh.disconnect();
System.out.println("Disconnect...");
} catch (Exception e) {
System.out.println("L'exception suivante s'est produite : "
+ e.getLocalizedMessage());
}
}
} |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
5 nov. 2009 13:03:37 com.sshtools.j2ssh.transport.cipher.SshCipherFactory <clinit>
INFO: Loading supported cipher algorithms
5 nov. 2009 13:03:37 com.sshtools.j2ssh.transport.kex.SshKeyExchangeFactory <clinit>
INFO: Loading key exchange methods
5 nov. 2009 13:03:37 com.sshtools.j2ssh.configuration.ConfigurationLoader initialize
INFO: JAVA version is 1.6.0_15
5 nov. 2009 13:03:37 com.sshtools.j2ssh.configuration.ConfigurationLoader initialize
INFO: Extension C:\Program Files\Java\jre6\lib\ext\dnsns.jar being added to classpath
5 nov. 2009 13:03:37 com.sshtools.j2ssh.util.ExtensionClassLoader add
INFO: Adding C:\Program Files\Java\jre6\lib\ext\dnsns.jar to the extension classpath
5 nov. 2009 13:03:37 com.sshtools.j2ssh.configuration.ConfigurationLoader initialize
INFO: Extension C:\Program Files\Java\jre6\lib\ext\localedata.jar being added to classpath
5 nov. 2009 13:03:37 com.sshtools.j2ssh.util.ExtensionClassLoader add
INFO: Adding C:\Program Files\Java\jre6\lib\ext\localedata.jar to the extension classpath
5 nov. 2009 13:03:37 com.sshtools.j2ssh.configuration.ConfigurationLoader initialize
INFO: Extension C:\Program Files\Java\jre6\lib\ext\sunjce_provider.jar being added to classpath
5 nov. 2009 13:03:37 com.sshtools.j2ssh.util.ExtensionClassLoader add
INFO: Adding C:\Program Files\Java\jre6\lib\ext\sunjce_provider.jar to the extension classpath
5 nov. 2009 13:03:37 com.sshtools.j2ssh.configuration.ConfigurationLoader initialize
INFO: Extension C:\Program Files\Java\jre6\lib\ext\sunmscapi.jar being added to classpath
5 nov. 2009 13:03:37 com.sshtools.j2ssh.util.ExtensionClassLoader add
INFO: Adding C:\Program Files\Java\jre6\lib\ext\sunmscapi.jar to the extension classpath
5 nov. 2009 13:03:37 com.sshtools.j2ssh.configuration.ConfigurationLoader initialize
INFO: Extension C:\Program Files\Java\jre6\lib\ext\sunpkcs11.jar being added to classpath
5 nov. 2009 13:03:37 com.sshtools.j2ssh.util.ExtensionClassLoader add
INFO: Adding C:\Program Files\Java\jre6\lib\ext\sunpkcs11.jar to the extension classpath
5 nov. 2009 13:03:37 com.sshtools.j2ssh.transport.publickey.SshKeyPairFactory <clinit>
INFO: Loading public key algorithms
5 nov. 2009 13:03:37 com.sshtools.j2ssh.transport.compression.SshCompressionFactory <clinit>
INFO: Loading compression methods
5 nov. 2009 13:03:37 com.sshtools.j2ssh.transport.hmac.SshHmacFactory <clinit>
INFO: Loading message authentication methods
5 nov. 2009 13:03:37 com.sshtools.j2ssh.transport.TransportProtocolCommon startTransportProtocol
INFO: Starting transport protocol
5 nov. 2009 13:03:37 com.sshtools.j2ssh.transport.TransportProtocolCommon run
INFO: Registering transport protocol messages with inputstream
5 nov. 2009 13:03:38 com.sshtools.j2ssh.transport.TransportProtocolCommon negotiateVersion
INFO: Negotiating protocol version
5 nov. 2009 13:03:38 com.sshtools.j2ssh.transport.TransportProtocolCommon negotiateVersion
INFO: Protocol negotiation complete
5 nov. 2009 13:03:38 com.sshtools.j2ssh.transport.TransportProtocolCommon beginKeyExchange
INFO: Starting key exchange
5 nov. 2009 13:03:38 com.sshtools.j2ssh.transport.kex.DhGroup1Sha1 performClientExchange
INFO: Starting client side key exchange.
5 nov. 2009 13:03:38 com.sshtools.j2ssh.transport.TransportProtocolCommon run
GRAVE: The Transport Protocol thread failed
java.io.IOException: The socket is EOF
at com.sshtools.j2ssh.transport.TransportProtocolInputStream.readBufferedData(Unknown Source)
at com.sshtools.j2ssh.transport.TransportProtocolInputStream.readMessage(Unknown Source)
at com.sshtools.j2ssh.transport.TransportProtocolCommon.readMessage(Unknown Source)
at com.sshtools.j2ssh.transport.kex.DhGroup1Sha1.performClientExchange(Unknown Source)
at com.sshtools.j2ssh.transport.TransportProtocolClient.performKeyExchange(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)
at java.lang.Thread.run(Unknown Source)
L'exception suivante s'est produite : The socket is EOF |
le problème se situe au niveau de l'instruction :
Code:
ssh.connect(hostname, 22);
pourtant, j'ai bien inclut tous les Jar nécessaires (inclus dans le package de l'API). J'utilise java 1.6.
Si quelqu'un a déjà essayé une API qui ne fait pas de problèmes. Je suis partant. Mon but étant d'envoyer et de recevoir des fichiers sur un serveur en utilisant SFTP.
Merci d'avance pour vos réponses.