J'essaie de faire un SFTP en utilisant JSch, mais j'ai rencontré une erreur:
com.jcraft.jsch.JSchException: le chiffre 'aes256-cbc' est requis, mais il n'est pas disponible.
Voici le code que j'ai utilisé. Y a-t-il quelque chose que j'ai raté?
JSch jsch = new JSch();
Session session = null;
jsch.addIdentity("C:\\privatekey.ppk", "Password");
session = jsch.getSession("user", "54.251.240.234", 22);
session.setConfig("StrictHostKeyChecking", "no");
Channel channel = session.openChannel("sftp");
channel.connect();
ChannelSftp sftpChannel = (ChannelSftp) channel;
sftpChannel.put("C:\\Users\\test.txt", "/home/user/test.txt");
sftpChannel.exit();
session.disconnect();
Trace de la pile
[8/30/13 1:56:26:556 SGT] 00000021 SystemErr R com.jcraft.jsch.JSchException: The cipher 'aes256-cbc' is required, but it is not available.
[8/30/13 1:56:26:557 SGT] 00000021 SystemErr R at com.jcraft.jsch.KeyPair.loadPPK(KeyPair.Java:1017)
[8/30/13 1:56:26:557 SGT] 00000021 SystemErr R at com.jcraft.jsch.KeyPair.load(KeyPair.Java:590)
[8/30/13 1:56:26:557 SGT] 00000021 SystemErr R at com.jcraft.jsch.KeyPair.load(KeyPair.Java:542)
[8/30/13 1:56:26:557 SGT] 00000021 SystemErr R at com.jcraft.jsch.IdentityFile.newInstance(IdentityFile.Java:40)
[8/30/13 1:56:26:558 SGT] 00000021 SystemErr R at com.jcraft.jsch.JSch.addIdentity(JSch.Java:389)
[8/30/13 1:56:26:558 SGT] 00000021 SystemErr R at com.jcraft.jsch.JSch.addIdentity(JSch.Java:370)
[8/30/13 1:56:26:558 SGT] 00000021 SystemErr R at com.belsize.sb.SB_UtilityBean.runExternalProgram_Windows(SB_UtilityBean.Java:1134)
[8/30/13 1:56:26:558 SGT] 00000021 SystemErr R at com.belsize.sb.EJSLocal0SLSB_Utility_861cc9f0.runExternalProgram_Windows(EJSLocal0SLSB_Utility_861cc9f0.Java)
[8/30/13 1:56:26:558 SGT] 00000021 SystemErr R at com.belsize.sb.SB_IntegrationBean.getFTP_Status(SB_IntegrationBean.Java:2175)
[8/30/13 1:56:26:559 SGT] 00000021 SystemErr R at com.belsize.sb.EJSLocal0SLSB_Integration_13682180.getFTP_Status(EJSLocal0SLSB_Integration_13682180.Java)
[8/30/13 1:56:26:559 SGT] 00000021 SystemErr R at pagecode.module.user_permission.W_useraccount.getFTP_Status(W_useraccount.Java:992)
[8/30/13 1:56:26:559 SGT] 00000021 SystemErr R at pagecode.module.user_permission.Up1006.doUp1006_commandlink_testftpAction(Up1006.Java:711)
[8/30/13 1:56:26:559 SGT] 00000021 SystemErr R at Sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[8/30/13 1:56:26:560 SGT] 00000021 SystemErr R at Sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.Java:60)
[8/30/13 1:56:26:560 SGT] 00000021 SystemErr R at Sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.Java:37)
[8/30/13 1:56:26:560 SGT] 00000021 SystemErr R at Java.lang.reflect.Method.invoke(Method.Java:611)
[8/30/13 1:56:26:560 SGT] 00000021 SystemErr R at org.Apache.el.parser.AstValue.invoke(AstValue.Java:268)
[8/30/13 1:56:26:560 SGT] 00000021 SystemErr R at org.Apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.Java:278)
[8/30/13 1:56:26:561 SGT] 00000021 SystemErr R at org.Apache.myfaces.view.facelets.el.TagMethodExpression.invoke(TagMethodExpression.Java:83)
[8/30/13 1:56:26:561 SGT] 00000021 SystemErr R at javax.faces.component._MethodExpressionToMethodBinding.invoke(_MethodExpressionToMethodBinding.Java:88)
[8/30/13 1:56:26:561 SGT] 00000021 SystemErr R at org.Apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.Java:100)
[8/30/13 1:56:26:561 SGT] 00000021 SystemErr R at javax.faces.component.UICommand.broadcast(UICommand.Java:120)
[8/30/13 1:56:26:561 SGT] 00000021 SystemErr R at javax.faces.component.UIViewRoot._broadcastAll(UIViewRoot.Java:973)
[8/30/13 1:56:26:562 SGT] 00000021 SystemErr R at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.Java:275)
[8/30/13 1:56:26:562 SGT] 00000021 SystemErr R at javax.faces.component.UIViewRoot._process(UIViewRoot.Java:1285)
[8/30/13 1:56:26:562 SGT] 00000021 SystemErr R at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.Java:711)
[8/30/13 1:56:26:562 SGT] 00000021 SystemErr R at org.Apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.Java:34)
[8/30/13 1:56:26:562 SGT] 00000021 SystemErr R at org.Apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.Java:171)
[8/30/13 1:56:26:563 SGT] 00000021 SystemErr R at org.Apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.Java:118)
[8/30/13 1:56:26:563 SGT] 00000021 SystemErr R at javax.faces.webapp.FacesServlet.service(FacesServlet.Java:189)
[8/30/13 1:56:26:563 SGT] 00000021 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.Java:1225)
[8/30/13 1:56:26:563 SGT] 00000021 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.Java:775)
[8/30/13 1:56:26:564 SGT] 00000021 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.Java:457)
[8/30/13 1:56:26:564 SGT] 00000021 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.Java:178)
[8/30/13 1:56:26:564 SGT] 00000021 SystemErr R at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.Java:136)
[8/30/13 1:56:26:564 SGT] 00000021 SystemErr R at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.Java:97)
[8/30/13 1:56:26:564 SGT] 00000021 SystemErr R at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.Java:77)
[8/30/13 1:56:26:564 SGT] 00000021 SystemErr R at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.Java:195)
[8/30/13 1:56:26:565 SGT] 00000021 SystemErr R at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.Java:91)
[8/30/13 1:56:26:565 SGT] 00000021 SystemErr R at com.belsize.servlet.filter.RedirectLogin.doFilter(RedirectLogin.Java:177)
[8/30/13 1:56:26:565 SGT] 00000021 SystemErr R at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.Java:195)
[8/30/13 1:56:26:565 SGT] 00000021 SystemErr R at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.Java:91)
[8/30/13 1:56:26:565 SGT] 00000021 SystemErr R at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.Java:928)
[8/30/13 1:56:26:565 SGT] 00000021 SystemErr R at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.Java:1025)
[8/30/13 1:56:26:566 SGT] 00000021 SystemErr R at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.Java:87)
[8/30/13 1:56:26:566 SGT] 00000021 SystemErr R at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.Java:908)
[8/30/13 1:56:26:566 SGT] 00000021 SystemErr R at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.Java:1662)
[8/30/13 1:56:26:566 SGT] 00000021 SystemErr R at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.Java:195)
[8/30/13 1:56:26:566 SGT] 00000021 SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.Java:453)
[8/30/13 1:56:26:566 SGT] 00000021 SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.Java:515)
[8/30/13 1:56:26:567 SGT] 00000021 SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.Java:306)
[8/30/13 1:56:26:567 SGT] 00000021 SystemErr R at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.Java:83)
[8/30/13 1:56:26:567 SGT] 00000021 SystemErr R at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.Java:166)
[8/30/13 1:56:26:567 SGT] 00000021 SystemErr R at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.Java:217)
[8/30/13 1:56:26:567 SGT] 00000021 SystemErr R at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.Java:161)
[8/30/13 1:56:26:568 SGT] 00000021 SystemErr R at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.Java:138)
[8/30/13 1:56:26:568 SGT] 00000021 SystemErr R at com.ibm.io.async.ResultHandler.complete(ResultHandler.Java:204)
[8/30/13 1:56:26:568 SGT] 00000021 SystemErr R at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.Java:775)
[8/30/13 1:56:26:568 SGT] 00000021 SystemErr R at com.ibm.io.async.ResultHandler$2.run(ResultHandler.Java:905)
[8/30/13 1:56:26:568 SGT] 00000021 SystemErr R at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.Java:1691)
Cette erreur apparaît également lorsque votre clé privée est au format PuTTY et non au format ssh ouvert.
Vous pouvez convertir la clé avec l'outil puttygen en une clé privée au format ssh ouvert.
Cela résout le problème pour moi. Le remplacement des fichiers Java Java n'était pas nécessaire dans mon cas avec netbeans 8.0.2 et Java 8_25.
Par défaut, les politiques JCE -qui viennent avec votre JDK ou JRE- ne prennent pas en charge de telles techniques de chiffrement comme (ase-256, .. etc.).
Bien sûr, vous DEVEZ remplacer vos jars JCE actuels (qui existent sur $ Java_HOME/jre/lib/security) par une version Jave compatible que vous avez sur le site Web d'Oracle.
Pour JDK 1.6: http://www.Oracle.com/technetwork/Java/javase/downloads/jce-6-download-429243.html Lien corrigé
Pour JDK 1.7: http://www.Oracle.com/technetwork/Java/javase/downloads/jce-7-download-432124.html
Pour JDK 1.8: http://www.Oracle.com/technetwork/Java/javase/downloads/jce8-download-2133166.html
Cela résoudra le problème.
Vous devez ajouter à votre JRE - Java politique de force illimitée, par exemple: http://www.Oracle.com/technetwork/Java/javase/downloads/jce-6 -download-429243.html Veuillez remplacer local_policy et us_export_policy sur le chemin JRE du serveur (\ lib\security) Une autre version des politiques JCE se trouve sur les pages Web d'Oracle.