jsch

JSch Exec output for error

大城市里の小女人 提交于 2019-12-09 01:02:34
问题 I need to run shell script at a remote machine. I am using JSch to connect to the remote machine and executing the shell script using ChannelExec . I need to know how I can get to know, if there was any error while execution of the command. Following is my code ChannelExec channel = (ChannelExec) session.openChannel("exec"); BufferedReader in = new BufferedReader(new InputStreamReader(channel.getInputStream())); String command = scriptName; if(parameter != null && !parameter.isEmpty()){

Generating a 4096-bit RSA key is way slower than 2048-bit using Jsch

浪子不回头ぞ 提交于 2019-12-08 17:24:46
问题 I need to create public and private RSA keys for a client/server application, and I'm using the JSch library to do so. I've been generating 4096-bit keys up until now, as I'd like to have the best security possible. However, this takes 3~5 minutes, whereas generating a 2048-bit key takes something to the tune of 10 seconds. Have an sscce: import com.jcraft.jsch.JSch; import com.jcraft.jsch.JSchException; import com.jcraft.jsch.KeyPair; public class KeyGenerator { public static void main

JSch Socket timeout - Connection timeout

孤者浪人 提交于 2019-12-08 15:07:11
问题 I am trying to establish an SFTP session using JSch. The code is working correctly and I am able to establish a session with multiple servers. However, today I am encountering an issue with one of the server. Caused by: com.jcraft.jsch.JSchException: java.net.ConnectException: Connection timed out: connect at com.jcraft.jsch.Util.createSocket(Util.java:349) ~[jsch-0.1.54.jar:?] at com.jcraft.jsch.Session.connect(Session.java:215) ~[jsch-0.1.54.jar:?] at com.jcraft.jsch.Session.connect(Session

JSch scp without known_host file and with StrictHostKeyChecking

家住魔仙堡 提交于 2019-12-08 12:37:01
问题 I am trying to copy some files from a Windows machine to a Linux machine, which is working fine with JSch so far. I can copy files using StrictHostKeyChecking no or I need to have the known_host file from the Linux machine I copy to. I am using the code for a Java project which should be able to send files automatically to (unknown) Linux machines. I got the username, password, IP and the publickey for the machine. Is there any way to authenticate without the known_host file and via the

The cipher 'aes256-cbc' is required, but it is not available

谁都会走 提交于 2019-12-08 12:33:23
问题 I am trying to do an SFTP using JSch, but I encountered some error: com.jcraft.jsch.JSchException: The cipher 'aes256-cbc' is required, but it is not available. Below is the code I used. Is there anything I missed out? 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();

JSchException: connection is closed by foreign host

♀尐吖头ヾ 提交于 2019-12-08 12:18:33
问题 Am trying to pull files from an SFTP server using JSCH. I am getting the files without any problem from local host, but from the cloud server(SAP Cloud Platform), its giving this Connection Is Closed By Foreign Host exception from JSCH. I am getting the system proxy and port and setting the proxy with the request. Had seen the question asked several times, but none of them is solving my problem. The code snippet : String SFTPHOST = "hostname"; int SFTPPORT = 22; String SFTPUSER = "username";

Change System.in and read System.out programmly on the fly (Jsch)

落花浮王杯 提交于 2019-12-08 10:18:05
问题 In my code I am trying to run some commands on a remote server via SSH. The commands must build on each other, but with a logic behind it. This means something like: When the output of command a contains “retcode 0”, then do command b. Else do command c I found no way to implement this logic into several “exec” commands. It seems like every “exec” has its own process, so I can’t continue where I was before. And with one “exec” I just can pass a list of commands where all of them will be

file uploading successfully, but 0kb file is uploading on remote server using jsch sftp java

谁说胖子不能爱 提交于 2019-12-08 09:36:52
问题 I am uploading a file from my local computer to remote server in a simple java application using Jsch, and Sftp protocol. My code is getting no error or no exception and it runs successfully, but when I look at the remote location, the file is uploaded as 0kb with no extension and named as 'D'. I have tried many ways but I am not able to figure out the mistake. Here is my code.. String remoteDirectory = "D:\\Datastores\\RootStore\\Test\\"; String localDirectory = "C:\\pdffiles\\"; String

SSHClient jsch bufferedinputstream LOCK

旧街凉风 提交于 2019-12-08 09:10:03
问题 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

How to detect error (as in “Directory not found”, “TNS listener lost contact”, etc) in JSch?

不问归期 提交于 2019-12-08 08:43:17
问题 I need to get error message while firing any command using JSch. Currently I am using below code to get output of tail command, but if the file does not exist, I should get the error as output (which I am not getting). public String getOutput() { LOGGER.debug("[getOutput]"); StringBuffer output = new StringBuffer(); InputStream in = null; if (channel != null && channel.isConnected()) { try { in = channel.getInputStream(); byte[] tmp = new byte[1024]; while (true) { LOGGER.debug("[getOutput]