jsch

Java 1.7 + JSCH: java.security.InvalidKeyException: Key is too long for this algorithm

谁说我不能喝 提交于 2019-12-06 21:06:49
问题 I'm trying to use JSCH to upload a file to a remote SFTP share. Every time I attempt to connect to the share from within my code, I get an exception that looks something like this: com.jcraft.jsch.JSchException: Session.connect: java.security.InvalidKeyException: Key is too long for this algorithm at com.jcraft.jsch.Session.connect(Session.java:558) ~[jsch-0.1.51.jar:na] at com.jcraft.jsch.Session.connect(Session.java:183) ~[jsch-0.1.51.jar:na] I've seen posts that describe this error when

SSHClient jsch bufferedinputstream LOCK

做~自己de王妃 提交于 2019-12-06 16:44:42
When executing command via SShClient based on jsch session get lock: Exec thread devapp090@1046" prio=5 tid=0x14 nid=NA runnable java.lang.Thread.State: RUNNABLE at java.io.FileInputStream.readBytes(FileInputStream.java:-1) at java.io.FileInputStream.read(FileInputStream.java:220) at java.io.BufferedInputStream.read1(BufferedInputStream.java:256) at java.io.BufferedInputStream.read(BufferedInputStream.java:317) - locked <0x420> (a java.io.BufferedInputStream) at com.jcraft.jsch.ChannelSession.run(ChannelSession.java:245) at java.lang.Thread.run(Thread.java:662) Here how I call client: client

Query regarding com.jcraft.jsch.JSchException: UnknownHostKey: x.y.com. DSA key fingerprint is “ac:ew:…”

倖福魔咒の 提交于 2019-12-06 16:25:33
I am getting below error while trying to connect to one of the windows server from AWS cluster. Caused by: com.jcraft.jsch.JSchException: UnknownHostKey: x.y.com. DSA key fingerprint is "ac:ew:..... Note: I generated the RSA keys using PuTTYgen, but every time it tries to connect it gives issue with DSA fingerprint. I referred multiple SO links but unable to get the right solution. Finally I tried below approach based on one of the posts. Get the session first time with StrictHostKeyChecking as no . Once done, save the result to known hosts file on the AWS server so that next time it tries to

List complete hierarchy of a directories at SFTP server using JSch in Java

♀尐吖头ヾ 提交于 2019-12-06 16:16:26
I want to display complete hierarchy of a directory at a remote location using JSch. The location has multiple folders and a folder may or may not have files. Code written by me (taken reference from SFTP Read all files in directory ): sftpChannel.cd(remotePath); Vector<String> files = sftpChannel.ls("*"); List<String> ret=new ArrayList<>(); for (int i = 0; i < files.size(); i++) { Object obj = files.elementAt(i); if (obj instanceof com.jcraft.jsch.ChannelSftp.LsEntry) { LsEntry entry = (LsEntry) obj; if (true && !entry.getAttrs().isDir()) { ret.add(entry.getFilename()+"file"); } if (true &&

Mocking Sftp class skip method call

帅比萌擦擦* 提交于 2019-12-06 16:02:11
public class SFTP { public Map<Report, TransferStatus> transfer(List<Report> reports) { //testing logic here } private ChannelSftp channelSftp; private Session session; private TransferStatus send(File file) { connect(); send(stream, file.getName()); } private void send(FileInputStream stream, String name) throws SftpException, IOException { channelSftp.put(stream, fileNameWithId, new SftpLogMonitor(), ChannelSftp.OVERWRITE); stream.close(); } private void connect() throws JSchException { if (session != null && channelSftp != null) { return; } JSch jsch = new JSch(); jsch.addIdentity

“Received message is too long” when connecting using Ant/JSch to SFTP server

吃可爱长大的小学妹 提交于 2019-12-06 15:13:35
I would like to upload a file from my local unix machine to a remote server that supports SFTP. I tried to implement using Ant script that used SCP task with sftp attribute set to true, but it didn't work, since it would always error out: com.jcraft.jsch.JSchException: 4: Received message is too long: 1416128878. If you can help me achieve that using shell script that should resolve the issue. Also will I have to install sftp or something on my local machine so that the script works? Any help here would be greatly appreciated. Cheers, Ashley Your Ant script works. It's the server that does not

Getting “Auth cancel” when authenticating using password with JSch

旧巷老猫 提交于 2019-12-06 13:45:35
I'm trying to execute a Unix command from Java. I'm using the JSch library. Here's my code: try{ Session session = new JSch().getSession("*****", "****", 22); session.setPassword("****"); java.util.Properties config = new java.util.Properties(); config.put("StrictHostKeyChecking", "no"); session.setConfig(config); session.connect(); Channel channel=session.openChannel("exec"); ((ChannelExec)channel).setCommand("pwd"); InputStream in=channel.getInputStream(); byte[] tmp=new byte[1024]; while(in.available()>0){ int i=in.read(tmp, 0, 1024); System.out.print(new String(tmp, 0, i)); } channel

Problems with Ant optional tasks SSHExec and SCP. Classpath issue?

。_饼干妹妹 提交于 2019-12-06 13:30:59
问题 I'm in the process of modifying an Ant script (currently in use from within MyEclipse) to work from the command line. I'm doing this so anyone can check out the project and build it without MyEclipse. The problem I'm running into is that MyEclipse includes the dependencies behind the scenes. It does this by looking at the workspace's Ant configuration and compiling the classpath based on the selected libraries in the preferences dialog. Long story short, I need to take those dependencies and

Wait for JSch command to execute instead of hard coding a fixed time to wait for

梦想与她 提交于 2019-12-06 12:54:37
问题 Channel channel=session.openChannel("shell"); channel.setInputStream(System.in); channel.setOutputStream(System.out); channel.connect(); while (channel.getExitStatus() == -1){ try{Thread.sleep(1000);}catch(Exception e){System.out.println(e);} } channel.disconnect(); In the code above we add line Thread.sleep(1000); to give the system enough time, to execute the command. However when I change the time gap from 1000 ms to 200 ms , the command doesn't execute. Also in some slow servers, the

Basic SSH connection via JSCH on android

孤人 提交于 2019-12-06 12:24:46
问题 As the fellow user from this question and this tutorial explain, I'm trying to setup a simples ssh connection to perform a single command on a app. It dosen't even need to wait for any response. Here is the code: Main Activity: package com.example.lucas.shutdown; import android.os.AsyncTask; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import com.jcraft.jsch.Channel; import com.jcraft.jsch.ChannelExec; import com.jcraft.jsch.JSch; import